我正在为我的网站使用html模板。谷歌地图在我的本地主机上运行良好,但当我将其上传到服务器上时,它在显示谷歌地图时显示错误。
我尝试使用谷歌api密钥,但它仍然不能工作,并在屏幕上得到javascript错误。
请查收附件中的图片供您参考。
请指教我该怎么做。

发布于 2017-06-14 17:20:36
Maps.html
替换googlemaps API的密钥
<!DOCTYPE html>
<html>
<body>
<div id="map" style="width:100%;height:500px"></div>
<script>
function myMap() {
var text="hello";
var myCenter = new google.maps.LatLng(51.508742,-0.120850);
var mapCanvas = document.getElementById("map");
var mapOptions = {center: myCenter, zoom: 5};
var map = new google.maps.Map(mapCanvas, mapOptions);
var marker = new google.maps.Marker({position:myCenter});
marker.setMap(map);
google.maps.event.addListener(marker,'click',function() {
var infowindow = new google.maps.InfoWindow({
content: text
});
infowindow.open(map,marker);
});
}
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=REPLACEKEY&callback=myMap"></script>
</body>
</html>https://stackoverflow.com/questions/44540021
复制相似问题