2012-02-17 69 views

回答

0

從谷歌演示

navigator.geolocation.getCurrentPosition(function(position) { 
    initialLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude); 
map.setCenter(initialLocation); 

由於initialLocation是全球性的,你可以用它來設置點擊事件監聽器:只需將地圖設爲initialLocation

google.maps.event.addDomListener(controlUI, 'click', function() { 
map.setCenter(initialLocation) 
}); 
相關問題