javascript - 我的谷歌地图(带有 JS 的静态 html)不会突然出现?

标签 javascript jquery html css google-maps

到昨天为止,我的PC应用程序生成的HTML map 文件可以显示了。 但是今天早上突然 map 不显示了?我真的不知道 原来它有效,突然间它现在不起作用了? 是否有任何 API 更新导致此问题?

有人可以帮忙看看我的 html 文件如下吗? 您可以尝试将以下 HTML 代码复制并粘贴到文件中并另存为 html 文件, 然后单击打开 HTML 文件, map 就不会显示?

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css"></link>
<script
src="http://maps.google.co.jp/maps?file=api&amp;v=2&amp;key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA&hl=ja"type="text/javascript"></script>
<script type="text/javascript">
var stzoom=13;
var map;
function init(){
if (GBrowserIsCompatible()){
map=new GMap2(document.getElementById("map_canvas"));
var mapui = map.getDefaultUI();
mapui.maptypes.physical = false;
map.setUI(mapui);
map.setCenter(new GLatLng(0,0),0);
bounds = new GLatLngBounds();
var polyOptions = {geodesic:true};
function addIcon(icon) { 
icon.iconSize = new GSize(48, 48);
icon.shadowSize = new GSize(48, 48);
icon.iconAnchor = new GPoint(24, 45);
icon.infoWindowAnchor = new GPoint(24, 24); }
var newIcon = new GIcon();
newIcon.image = "C:/Program Files/TransTechnology/Enjoy ARES/Image/goal.png";
addIcon(newIcon);
var newIcon1 = new GIcon();
newIcon1.image = "C:/Program Files/TransTechnology/Enjoy ARES/Image/start.png";
addIcon(newIcon1);
var newIcon2 = new GIcon();
newIcon2.image = "start.png";
addIcon(newIcon2);
var point0=new GLatLng(37.85383,138.9178);
var marker0=new GMarker(point0,{icon: newIcon1});
map.addOverlay(marker0);
var point1=new GLatLng(37.85387,138.9179);
var marker1=new GMarker(point1,{icon: newIcon});
map.addOverlay(marker1);
var polyline0= new GPolyline([new GLatLng(37.85383,138.9178),
new GLatLng(37.85374,138.9176),
new GLatLng(37.85365,138.9175),
new GLatLng(37.85355,138.9173),
new GLatLng(37.85347,138.9171),
new GLatLng(37.85336,138.9169),
new GLatLng(37.85326,138.9167),
new GLatLng(37.85317,138.9165),
new GLatLng(37.85305,138.9163),
new GLatLng(37.85297,138.9161),
new GLatLng(37.8529,138.9159),
new GLatLng(37.85279,138.9157),
new GLatLng(37.85269,138.9155),
new GLatLng(37.85267,138.9157),
new GLatLng(37.85264,138.9159),
new GLatLng(37.85255,138.916),
new GLatLng(37.85291,138.9158),
new GLatLng(37.85302,138.916),
new GLatLng(37.85313,138.9162),
new GLatLng(37.85321,138.9164),
new GLatLng(37.85334,138.9167),
new GLatLng(37.85344,138.9169),
new GLatLng(37.85355,138.9172),
new GLatLng(37.8537,138.9174),
new GLatLng(37.85381,138.9177),
new GLatLng(37.85389,138.9179),
new GLatLng(37.85404,138.9181),
new GLatLng(37.854,138.9181),
new GLatLng(37.85387,138.9179)],"#ff0000", 5, 0.7, polyOptions);
map.addOverlay(polyline0);
bounds.extend(new GLatLng(37.84937, 138.9032));
bounds.extend(new GLatLng(37.87642, 138.9412));
map.setZoom(map.getBoundsZoomLevel(bounds));
map.setCenter(bounds.getCenter());
}
}
window.onload=init;
</script>
</head>
<body scroll=no>
<div id="map_canvas" style="width: 1024px; height: 706px; position: absolute; left: 0; top: 0">
<font size="5" color="#cc0000">
<div align="center">
<p><marquee></marquee></p>
<p><marquee></marquee></p>
<p><marquee></marquee></p>
<p><marquee></marquee></p>
<p><marquee></marquee></p>
<p><marquee>
We are sorry that the map cannot be shown...... 
</marquee></p>
</font></div>
</body>
</html>

最佳答案

您正在使用 Google Maps Javascript API v2:

<script src="http://maps.google.co.jp/maps?file=api&amp;v=2&amp;key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA&hl=ja"type="text/javascript"></script>

Google Maps Javascript API v2 已被关闭。它已被 Google Maps Javascript API v3 的包装版本所取代,正如在最初的弃用期结束的过去 6 个月中所宣传的那样。

来自 the documentation :

Warning: Version 2 of the Google Maps JavaScript API is no longer available for new applications and will be turned down for existing applications on November 19, 2013. Please follow the guide to migrate your code to version 3 of the Google Maps JavaScript API. As of November 19, 2013, all applications requesting v2 will be served a special, wrapped version of the v3 API instead. We expect this wrapped version of the API will work for most simple maps, but we strongly encourage you to migrate to the v3 API immediately.

关于javascript - 我的谷歌地图(带有 JS 的静态 html)不会突然出现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20087709/

相关文章:

javascript - jquery 多个 slider 将值插入文本框

javascript - isObject 测试到底是用来做什么的?

javascript - 未能对先前事件的元素调用操作

angularjs - 如何使angularjs网站加载速度更快

javascript - webpack 2.2.1 以错误的顺序/位置排列依赖项

javascript - 如果没有文件或函数名称,如何找到正在对元素进行更改的函数?

javascript - 如何使用 javascript 模拟鼠标点击(在 Google map 中)?

javascript - 我可以将 JS 脚本放在页脚上方而不是页脚下方 </body> 标记之前吗

javascript - 如何修改表行内的克隆字段表单值和id?

javascript - 语法错误? Jquery 脚本在 IE7 中不起作用