我遇到了一些問題。在這個網站(http://hyp.altervista.org/home.html)我想去頁面:位置,它應該出現我的谷歌地圖,由AJAX函數調用。通過ajax調用Google Maps Api不起作用
我有getLocation.php
通過AJAX調用:
<?php echo '<div id="map-canvas"></div>'; ?>
同時腳本:
window.onload = loadScript;
$.ajax({
method: "POST",
//dataType: "json", //type of data
crossDomain: true, //localhost purposes
url: "../getLocation.php", //Relative or absolute path to file.php file
success: function(response) {
$(".contenuti").html(" "+response);
},
error: function(request,error)
{
console.log("Error");
}
});
但我不能看地圖。我把谷歌的腳本家:
function initialize() {
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644)
};
var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
}
function loadScript() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp' +
'&signed_in=true&callback=initialize';
document.body.appendChild(script);
}
非常感謝! –