"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps JavaScript API Example</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA8yIYxazMxSwAr_Babur8wRTDWoii84C-sWRHj1b26mKdbcal3hToR1q1zJwLbhba-Q_N3ECrOi_UAA"
type="text/javascript"></script>
<script src="hammap.js" language="javascript" type="text/javascript" ></script>
</head>
<body onload="load()" onunload="GUnload()">
<div id="main" >太仓火腿地图(测试中)</div>
<div id="map" style="width: 800px; height: 500px"></div>
</body>
</html>
导入后还是无法显示,将hammap.js写在首页可以显示.什么问题?
9 个解决方案
#1
language="javascript" 去掉看
#2
还是没用!路径正确,和index文件在同一个目录!js文件没<script>标签!
#3
//<![CDATA[
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.enableScrollWheelZoom()
map.setMapType(G_NORMAL_MAP);//修改地图类型 必须放最后[G_SATELLITE_MAP | G_NORMAL_MAP | G_HYBRID_MAP]
map.setCenter(new GLatLng(31.462053, 121.131134), 11);
var me = new GLatLng(31.574653, 121.056934);
var bgqxw = new GMarker(me);
GEvent.addListener(bgqxw,"click",
function() {
var myHtml="BG4QXW<br/>江苏太仓沙溪";
bgqxw.openInfoWindowHtml(myHtml);
});
map.addOverlay(bgqxw);
var sfz = new GLatLng(31.446713, 121.102934);
var bhsfz = new GMarker(sfz);
GEvent.addListener(bhsfz,"click",
function() {
var sfzHtml="BH4SFZ<br/>江苏太仓市县府街";
bhsfz.openInfoWindowHtml(sfzHtml);
});
map.addOverlay(bhsfz);
var sgk = new GLatLng(31.442713, 121.106934);
var bhsgk = new GMarker(sgk);
GEvent.addListener(bhsgk,"click",
function() {
var sgkHtml="BH4SGK<br/>江苏太仓市";
bhsgk.openInfoWindowHtml(sgkHtml);
});
map.addOverlay(bhsgk);
var sgv = new GLatLng(31.444045, 121.100434);
var bhsgv = new GMarker(sgv);
GEvent.addListener(bhsgv,"click",
function() {
var sgvHtml="BH4SGV<br/>江苏太仓市人民医院";
bhsgv.openInfoWindowHtml(sgvHtml);
});
map.addOverlay(bhsgv);
}
}
//]]>
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.enableScrollWheelZoom()
map.setMapType(G_NORMAL_MAP);//修改地图类型 必须放最后[G_SATELLITE_MAP | G_NORMAL_MAP | G_HYBRID_MAP]
map.setCenter(new GLatLng(31.462053, 121.131134), 11);
var me = new GLatLng(31.574653, 121.056934);
var bgqxw = new GMarker(me);
GEvent.addListener(bgqxw,"click",
function() {
var myHtml="BG4QXW<br/>江苏太仓沙溪";
bgqxw.openInfoWindowHtml(myHtml);
});
map.addOverlay(bgqxw);
var sfz = new GLatLng(31.446713, 121.102934);
var bhsfz = new GMarker(sfz);
GEvent.addListener(bhsfz,"click",
function() {
var sfzHtml="BH4SFZ<br/>江苏太仓市县府街";
bhsfz.openInfoWindowHtml(sfzHtml);
});
map.addOverlay(bhsfz);
var sgk = new GLatLng(31.442713, 121.106934);
var bhsgk = new GMarker(sgk);
GEvent.addListener(bhsgk,"click",
function() {
var sgkHtml="BH4SGK<br/>江苏太仓市";
bhsgk.openInfoWindowHtml(sgkHtml);
});
map.addOverlay(bhsgk);
var sgv = new GLatLng(31.444045, 121.100434);
var bhsgv = new GMarker(sgv);
GEvent.addListener(bhsgv,"click",
function() {
var sgvHtml="BH4SGV<br/>江苏太仓市人民医院";
bhsgv.openInfoWindowHtml(sgvHtml);
});
map.addOverlay(bhsgv);
}
}
//]]>
#4
解决了!
#5
来jf了
#6
自行解决了。。。
#7
js文件有中文,编码不一样
#8
楼主是怎么解决的啊
#9
……LZ 自己就闪人了…… 正纳闷着呢,按理说 一定是你导入的路径有问题,或者你的html.js里其他js有错误,才导致 用不了
#1
language="javascript" 去掉看
#2
还是没用!路径正确,和index文件在同一个目录!js文件没<script>标签!
#3
//<![CDATA[
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.enableScrollWheelZoom()
map.setMapType(G_NORMAL_MAP);//修改地图类型 必须放最后[G_SATELLITE_MAP | G_NORMAL_MAP | G_HYBRID_MAP]
map.setCenter(new GLatLng(31.462053, 121.131134), 11);
var me = new GLatLng(31.574653, 121.056934);
var bgqxw = new GMarker(me);
GEvent.addListener(bgqxw,"click",
function() {
var myHtml="BG4QXW<br/>江苏太仓沙溪";
bgqxw.openInfoWindowHtml(myHtml);
});
map.addOverlay(bgqxw);
var sfz = new GLatLng(31.446713, 121.102934);
var bhsfz = new GMarker(sfz);
GEvent.addListener(bhsfz,"click",
function() {
var sfzHtml="BH4SFZ<br/>江苏太仓市县府街";
bhsfz.openInfoWindowHtml(sfzHtml);
});
map.addOverlay(bhsfz);
var sgk = new GLatLng(31.442713, 121.106934);
var bhsgk = new GMarker(sgk);
GEvent.addListener(bhsgk,"click",
function() {
var sgkHtml="BH4SGK<br/>江苏太仓市";
bhsgk.openInfoWindowHtml(sgkHtml);
});
map.addOverlay(bhsgk);
var sgv = new GLatLng(31.444045, 121.100434);
var bhsgv = new GMarker(sgv);
GEvent.addListener(bhsgv,"click",
function() {
var sgvHtml="BH4SGV<br/>江苏太仓市人民医院";
bhsgv.openInfoWindowHtml(sgvHtml);
});
map.addOverlay(bhsgv);
}
}
//]]>
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.enableScrollWheelZoom()
map.setMapType(G_NORMAL_MAP);//修改地图类型 必须放最后[G_SATELLITE_MAP | G_NORMAL_MAP | G_HYBRID_MAP]
map.setCenter(new GLatLng(31.462053, 121.131134), 11);
var me = new GLatLng(31.574653, 121.056934);
var bgqxw = new GMarker(me);
GEvent.addListener(bgqxw,"click",
function() {
var myHtml="BG4QXW<br/>江苏太仓沙溪";
bgqxw.openInfoWindowHtml(myHtml);
});
map.addOverlay(bgqxw);
var sfz = new GLatLng(31.446713, 121.102934);
var bhsfz = new GMarker(sfz);
GEvent.addListener(bhsfz,"click",
function() {
var sfzHtml="BH4SFZ<br/>江苏太仓市县府街";
bhsfz.openInfoWindowHtml(sfzHtml);
});
map.addOverlay(bhsfz);
var sgk = new GLatLng(31.442713, 121.106934);
var bhsgk = new GMarker(sgk);
GEvent.addListener(bhsgk,"click",
function() {
var sgkHtml="BH4SGK<br/>江苏太仓市";
bhsgk.openInfoWindowHtml(sgkHtml);
});
map.addOverlay(bhsgk);
var sgv = new GLatLng(31.444045, 121.100434);
var bhsgv = new GMarker(sgv);
GEvent.addListener(bhsgv,"click",
function() {
var sgvHtml="BH4SGV<br/>江苏太仓市人民医院";
bhsgv.openInfoWindowHtml(sgvHtml);
});
map.addOverlay(bhsgv);
}
}
//]]>
#4
解决了!
#5
来jf了
#6
自行解决了。。。
#7
js文件有中文,编码不一样
#8
楼主是怎么解决的啊
#9
……LZ 自己就闪人了…… 正纳闷着呢,按理说 一定是你导入的路径有问题,或者你的html.js里其他js有错误,才导致 用不了