Created
March 21, 2014 18:27
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//地図のインスタンスを取得します | |
var map = plugin.google.maps.Map.getMap(); | |
//初期化が完了するのを待ちます | |
map.addEventListener(plugin.google.maps.event.MAP_READY, function(map) { | |
//初期化が完了したら地図を表示します | |
map.showDialog(); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map.animateCamera({ | |
"target": new plugin.google.maps.LatLng(...), | |
"zoom": 18, | |
"tilt": 45, | |
"bearing": 90, | |
"duration": 3000 //ミリ秒で指定。省略した場合、4000ミリ秒(4秒) | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map.setMapTypeId(plugin.google.maps.HYBRID); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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