我有一个简单的应用程序,它将尝试加载谷歌地图。但是当我点击链接查看地图时。我得到了这个错误。
ReferenceError:未定义 GBrowserIsCompatible [中断此错误]
如果(GBrowserIsCompatible()){
这是我的代码
------------ 脚本 -------------
<script type="text/javascript"
src="http://maps.googleapis.com/maps/api/js?key=AIzaSyBQ8OCC8En5vNHod25Ov3Qs5E1v7NPRSsg&sensor=true">
</script>
<script type="text/javascript">
var map;
var geocoder;
//Show the google map
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("divMap"));
map.setUIToDefault();
geocoder = new GClientGeocoder();
}
}
//Show default address on map
function showTheMap() {
document.getElementById('divMap').style.display = "block";
initialize();
var address = document.getElementById("spAddress1").innerHTML;
geocoder.getLatLng(
address,
function (point) {
if (!point) {
alert(address + " not found");
}
else {
map.setCenter(point, 15);
var marker = new GMarker(point);
map.addOverlay(marker);
marker.openInfoWindow(address);
}
}
);
}
</script>
------------ HTML正文 ----------------
<span id="spAddress1" runat="server" ClientIDMode ="Static"></span>
<a onclick="showTheMap()" style="cursor: pointer;">
<span style="text-decoration:underline;">Click here to view map </span>
</a>
<div id="divMap" style="display: none; width: 100%; height: 500px;top: -220px">
</div>
谢谢
鲁伊