0
它顯示你想在url中分享你的位置,但不會顯示地圖。所以我想知道哪裏可以出問題?但它顯示在IE和Firefox,但沒有出現在Safari和Chrome谷歌地圖API:無法顯示地圖
$(document).ready(function(){
initialize();
$("#btInit").click(function(){
navigator.geolocation.getCurrentPosition(onSuccess);
}); //call this function when the user click
});
var map;
// MAP
function initialize() {
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
var mapOptions = {
zoom: 17
};
}
//地理位置
function onSuccess(position){
var myLat = position.coords.latitude;
var myLong = position.coords.longitude;
var latLng = new google.maps.LatLng(myLat, myLong);
map.setCenter(latLng);
google.maps.event.addDomListener(document, initialize);
我應該不得不關注此鏈接 http://www.paulund.co.uk/how-to-use-geolocation-api-with-google-maps –