level 1
txwtony
楼主
在百度地图输入 :上海市四川北路61号 看标记点 (这里没有写 虹口区)
写上虹口区: 上海市虹口区四川北路61号 标记点和地址解析的结果一样.但是貌似到黄浦区去了
如果地址解析里,不写虹口区 跑到浦东去了..这又是怎么回事??
大家可以自己试试.代码如下
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>地址解析</title>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>
</head>
<body>
<div style="width:520px;height:340px;border:1px solid gray" id="container"></div>
</body>
</html>
<script type="text/javascript">
var map = new BMap.Map("container");
map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);
// 创建地址解析器实例
var myGeo = new BMap.Geocoder();
// 将地址解析结果显示在地图上,并调整地图视野
myGeo.getPoint("虹口区四川北路61号", function(point){
if (point) {
map.centerAndZoom(point, 16);
map.addOverlay(new BMap.Marker(point));
}
}, "上海市"); </script>
2012年04月25日 02点04分
1
写上虹口区: 上海市虹口区四川北路61号 标记点和地址解析的结果一样.但是貌似到黄浦区去了
如果地址解析里,不写虹口区 跑到浦东去了..这又是怎么回事??
大家可以自己试试.代码如下
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>地址解析</title>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>
</head>
<body>
<div style="width:520px;height:340px;border:1px solid gray" id="container"></div>
</body>
</html>
<script type="text/javascript">
var map = new BMap.Map("container");
map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);
// 创建地址解析器实例
var myGeo = new BMap.Geocoder();
// 将地址解析结果显示在地图上,并调整地图视野
myGeo.getPoint("虹口区四川北路61号", function(point){
if (point) {
map.centerAndZoom(point, 16);
map.addOverlay(new BMap.Marker(point));
}
}, "上海市"); </script>