Google地图画布无法显示

时间:2011-11-10 00:56:23

标签: google-maps google-maps-api-2

我有一张没有显示的地图。

页面加载所有控件但地图画布无法加载。我不知道该在哪里看,因为这张地图多年来一直运行良好,但我已经更新了html,它已停止工作(见附件)

我已经尝试将它剥离到裸露的骨头,看看我是否可以使它工作(即只是地图,一个点和一个标记)但没有...我正在使用v2 - GMap2

    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAHXuavtLbrkcGH6cQdo3gBBS4qDQlwPUwKySmZaFjOqYCz5LrLRQqZperPeQ8BVZogxQeWtkVuxYdcQ" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" charset="utf-8">
    //<![CDATA[

    var map = null;

    function mapOnLoad() {
        if (GBrowserIsCompatible()) {

            var mapObj = document.getElementById("map");

            if (mapObj != "undefined" && mapObj != null) {
                map = new GMap2(document.getElementById("map"));
                map.setCenter(new GLatLng(-38.165295, 145.188317), 15, G_NORMAL_MAP);
                map.addControl(new GLargeMapControl3D());
                map.addControl(new GMenuMapTypeControl());
                map.addControl(new GScaleControl());
                var point = new GLatLng(-38.1652950000,145.1883170000);
                map.addOverlay(new GMarker(point));

            } else {
                alert("The map could not be displayed on your browser.");
            }
        }
    }
    //]]>
    </script>

<div id="map" class="map" style=""></div>

请帮忙!

Map Not Displaying

1 个答案:

答案 0 :(得分:1)

为我工作,试试这个:

<html>
<head>
<title>Google Maps JavaScript API Example</title>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAHXuavtLbrkcGH6cQdo3gBBS4qDQlwPUwKySmZaFjOqYCz5LrLRQqZperPeQ8BVZogxQeWtkVuxYdcQ" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" charset="utf-8">
    //<![CDATA[

    var map = null;

    function mapOnLoad() {
        if (GBrowserIsCompatible()) {

            var mapObj = document.getElementById("map");

            if (mapObj != "undefined" && mapObj != null) {
                map = new GMap2(document.getElementById("map"));
                map.setCenter(new GLatLng(-38.165295, 145.188317), 15, G_NORMAL_MAP);
                map.addControl(new GLargeMapControl3D());
                map.addControl(new GMenuMapTypeControl());
                map.addControl(new GScaleControl());
                var point = new GLatLng(-38.1652950000,145.1883170000);
                map.addOverlay(new GMarker(point));

            } else {
                alert("The map could not be displayed on your browser.");
            }
        }
    }
    //]]>
</script>
</head>
<body onload="mapOnLoad()" onunload="GUnload()">
    <div id="map" class="map" style="width: 500px; height: 300px"></div>
</body>