1

지도를 그리고 내 정확한 위치에 카메라를 움직이게하려면 다음 코드를 사용합니다. 정확한 위치는 & (정확한 숫자)입니다.하지만 현재 위치를 사용자에게 전달해야합니다. , 그래서 나는이 tutorial에이코도 바 Google지도 플러그인

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!"); 

     }); 
    }); 
    }); 
} 

답변

0

확인에 사용자의 현재 위치를 전달하는 방법을 알아야합니다. cordova-geolocation-plugin 또는 Cordova Background Geolocation을 사용하면 훨씬 더 안정적으로 작동하며 훨씬 더 많은 기능을 제공합니다. 결과를 다시지도 플러그인에 전달할 수 있습니다.

var onSuccess = function(location) { 
    var msg = ["Current your location:\n", 
    "latitude:" + location.latLng.lat, 
    "longitude:" + location.latLng.lng, 
    "speed:" + location.speed, 
    "time:" + location.time, 
    "bearing:" + location.bearing].join("\n"); 

    map.addMarker({ 
    'position': location.latLng, 
    'title': msg 
    }, function(marker) { 
    marker.showInfoWindow(); 
    }); 
}; 

var onError = function(msg) { 
    alert("error: " + msg); 
}; 
map.getMyLocation(onSuccess, onError); 

또한 SO post에 주어진 코드를 따라갈 수도 있습니다.

관련 문제