Skip to content

Instantly share code, notes, and snippets.

@wf9a5m75
Created March 21, 2014 18:27
Show Gist options
  • Save wf9a5m75/9692632 to your computer and use it in GitHub Desktop.
Save wf9a5m75/9692632 to your computer and use it in GitHub Desktop.
地図操作を行う:Google Maps Mobile SDK / Cordova(PhoneGap) ref: http://qiita.com/wf9a5m75/items/4a99b64be25dce27ca0d
//地図のインスタンスを取得します
var map = plugin.google.maps.Map.getMap();
//初期化が完了するのを待ちます
map.addEventListener(plugin.google.maps.event.MAP_READY, function(map) {
//初期化が完了したら地図を表示します
map.showDialog();
});
const GORYOKAKU_JAPAN = new plugin.google.maps.LatLng(41.796875,140.757007);
var map = plugin.google.maps.Map.getMap({
'mapType': plugin.google.maps.MapTypeId.HYBRID,
'controls': {
'compass': true,
'myLocationButton': true,
'indoorPicker': true,
'zoom': true
},
'gestures': {
'scroll': true,
'tilt': true,
'rotate': true
},
'camera': {
'latLng': GORYOKAKU_JAPAN,
'tilt': 30,
'zoom': 15,
'bearing': 50
}
});
map.animateCamera({
"target": new plugin.google.maps.LatLng(...),
"zoom": 18,
"tilt": 45,
"bearing": 90,
"duration": 3000 //ミリ秒で指定。省略した場合、4000ミリ秒(4秒)
});
map.getCameraPosition(function(camera) {
var buff = ["Current camera position:\n"
"latitude:" + camera.target.lat,
"longitude:" + camera.target.lng,
"zoom:" + camera.zoom,
"tilt:" + camera.tilt,
"bearing:" + camera.bearing].join("\n");
alert(buff);
});
map.setMapTypeId(plugin.google.maps.HYBRID);
map.on(plugin.google.maps.event.MAP_LONG_CLICK, function(latLng) {
alert("地図が長押しされました\n" +
latLng.toUrlValue());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment