Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
118 views
in Technique[技术] by (71.8m points)

javascript - Google Maps API: TypeError: a is undefined

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.

enter image description here

Please help

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...