1
地図を描画し、正確な緯度を正確に設定したときにのみ正しく動作する現在の場所にカメラをアニメーションするには、次のコードを使用します(正確な数値)。ユーザーの現在地を渡す必要がありますですので、私はこのtutorialでこのCordova google mapsプラグイン
var map;
document.addEventListener("deviceready", function() {
var div = document.getElementById("map_canvas");
// Initialize the map view
map = plugin.google.maps.Map.getMap(div);
// Wait until the map is ready status.
map.addEventListener(plugin.google.maps.event.MAP_READY, onMapReady);
}, false);
function onMapReady() {
// Move to the position with animation
map.animateCamera({
target: {lat: 30.1234567, lng: 31.1234567},
zoom: 17,
tilt: 60,
bearing: 140,
duration: 5000
}, function() {
// Add a maker
map.addMarker({
position: {lat: 30.1234567, lng: 31.1234567},
title: "Welecome to \n" +
"Cordova GoogleMaps plugin for iOS and Android",
snippet: "This plugin is awesome!",
animation: plugin.google.maps.Animation.BOUNCE
}, function(marker) {
// Show the info window
marker.showInfoWindow();
// Catch the click event
marker.on(plugin.google.maps.event.INFO_CLICK, function() {
// To do something...
alert("Hello world!");
});
});
});
}