以下作品。当我走遍办公室时,它会跟踪我:
(function() {
var Variables = {}
Variables.Counter = 0
google.maps.event.addDomListener(window, 'load', initialize);
function initialize() {
navigator.geolocation.getCurrentPosition(centerTheMap);
}
function centerTheMap(arg) {
$('.msg').text('latitude 1: ' + arg.coords.latitude + ', longitude: ' + arg.coords.longitude)
var mapOptions = {
center: new google.maps.LatLng(arg.coords.latitude, arg.coords.longitude)
,zoom: 18
};
Variables.myMap = new google.maps.Map(document.getElementById("map-canvas"),mapOptions);
var myLatlng = new google.maps.LatLng(arg.coords.latitude, arg.coords.longitude);
Variables.myMarker = new google.maps.Marker({
position: myLatlng,
map: Variables.myMap
});
navigator.geolocation.watchPosition(DisplayMyNewLocation);
}
function DisplayMyNewLocation(arg) {
Variables.Counter += 1
$('.msg').text('latitude ' + Variables.Counter + ': ' + arg.coords.latitude + ', longitude: ' + arg.coords.longitude)
Variables.myMarker.setPosition(new google.maps.LatLng(arg.coords.latitude, arg.coords.longitude))
}
})()
现在,我的问题在这里:
我希望它以1:3000的比例缩放,这样如果我走了一英里,就会跟踪我走过美国大陆。
所以它应该从我当前的位置开始,但是当我走路时它应该以1:3000的比例更新。