Google Maps API:TypeError:a未定义 [英] Google Maps API: TypeError: a is undefined
问题描述
我在网上搜索了这个问题,他们都没有给我任何解决方案。我有一个简单的脚本来显示南非的地图。
<!DOCTYPE html>
< html lang =en>
< head>
< meta charset =utf-8>
< meta http-equiv =x-ua-compatiblecontent =ie = edge,chrome = 1/>
< title>地图测试< /标题>
< script language =javascriptsrc =https://maps.googleapis.com/maps/api/js?sensor=true>< / script>
< style>
#map-canvas {
height:300px;
width:980px;
保证金:0;
padding:0;
margin-top:10px;
}
< / style>
< / head>
< body>
< div id =map-canvasclass =map_canvas>< / div>
< script type =text / javascript>
函数initialize()
{
var mapOptions = {
center:new google.maps.LatLng(-29.09958,26.18434),
zoom:5,
mapTypeControlOptions:{
position:google.maps.ControlPosition.TOP_LEFT
}
};
map = new google.maps.Map(document.getElementById('map-canvas'),mapOptions);
}
google.maps.event.addDomListener(window,'load',initialize);
< / script>
< / body>
< / html>
但是我总是一遍又一遍地得到相同的错误。我甚至在不同的服务器上试过。
请帮忙
我也经常在最后几天看到这个错误,实验性API版本似乎存在问题。
$ b
加载发布版本< script language =javascriptsrc =https://maps.googleapis.com/maps/api/js?sensor=true&v=3>< / script>
I have searched this problem all over the web and none of them seem to give me any resolution. I have a simple script to just display the map of South Africa.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge, chrome=1" />
<title>Map Test</title>
<script language="javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true"></script>
<style>
#map-canvas {
height: 300px;
width: 980px;
margin: 0;
padding: 0;
margin-top: 10px;
}
</style>
</head>
<body>
<div id="map-canvas" class="map_canvas"></div>
<script type="text/javascript">
function initialize()
{
var mapOptions = {
center: new google.maps.LatLng(-29.09958,26.18434),
zoom: 5,
mapTypeControlOptions: {
position: google.maps.ControlPosition.TOP_LEFT
}
};
map = new google.maps.Map(document.getElementById('map-canvas'),mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</body>
</html>
But I keep on getting the same error over and over. I have even tried on a different server.
Please help
I've also seen this error often in the last days, there seems to be an issue with the experimental API-version.
Load the release-version instead(basically you should always load the release-version in production)
<script language="javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true&v=3"></script>
这篇关于Google Maps API:TypeError:a未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!