怎样让Google地图显示指定的城市?

wzwen wzwen 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
比如我想显示上海的某条路,可是我这段代码一直显示的是北京。

我人为的更改了经纬度也不行。。。





<script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=ABQIAAAA9Ot9Dal8oVohqNGTUB61oRQLjaRHydcRGDb-HBpcbU38szWFQBR-wymCIqIGN6F1_4YQvg-O9H3ntg" type="text/javascript"></script>
<script type="text/javascript">

var map = null;
var geocoder = null;

function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(39.917, 116.397), 13);/*这里我改成(121.4838, 31.2517), 3也不行*/
geocoder = new GClientGeocoder();
}
}

function showAddress(address) {
if (geocoder) {
geocoder.getLatLng(
address,
function(point) {
if (!point) {
alert("不能解析: " + address);
} else {
map.setCenter(point, 13);
var marker = new GMarker(point);
map.addOverlay(marker);
marker.openInfoWindowHtml(address);
}
}
);
}
}
</script>

<body onload="initialize()" onunload="GUnload()">
〖地理位置〗
<div id="map_canvas" style="width: 500px; height: 300px"></div>

...全文
评论 6
收藏 已收藏
分享
返回顶部
wzwen
JavaScript 87,984 成员 224,681 内容