poi 解析中文_百度地图周边最近的POI查询并且解析出中文地址

举例:

百度经纬度:lat=30.52953&lon=120.43016

http://api.map.baidu.com/?qt=rgc&x=13407612.87&y=3550364.78&dis_poi=100&poi_num=10&ie=utf-8&oue=2&res=api&callback=BMap._rd._cbk30352

返回数据:

BMap._rd._cbk30352 && BMap._rd._cbk30352({"content":{"address":"浙江省嘉兴市桐乡市崇德中路47","address_detail":{"city":"嘉兴市","city_code":334,"district":"桐乡市","province":"浙江省","street":"崇德中路","street_number":"47"},"business":"","point":{"x":"13407612.87","y":"3550364.78"},"surround_poi":[{"addr":"崇德中路47","cp":"NavInfo","distance":"26.927155","name":"新华书店崇福店","poiType":"新华书店,图书音像,购物","point":{"x":"13407632.660000","y":"3550346.520000"},"tel":"(0573)88413730","uid":"1c18e2e892e17dabc61b75e4","zip":""},{"addr":"浙江省嘉兴市桐乡市","cp":"NavInfo","distance":"52.717770","name":"光明眼镜崇福店","poiType":"钟表眼镜,购物","point":{"x":"13407575.200000","y":"3550327.900000"},"tel":"","uid":"cde862b70813c6ee9ff779e4","zip":""},{"addr":"崇福镇崇德东路39号","cp":"NavInfo","distance":"56.255920","name":"红太阳KTV娱乐中心","poiType":"KTV,休闲娱乐","point":{"x":"13407668.160000","y":"3550354.400000"},"tel":"(0573)88411218","uid":"ecd5e611cc428d06b72655e4","zip":""},{"addr":"银都中路66号","cp":"NavInfo","distance":"76.699611","name":"金鑫大厦","poiType":"办公大厦,商务大厦","point":{"x":"13407537.350000","y":"3550351.380000"},"tel":"","uid":"0c18663c996927a040ab9ae6","zip":""},{"addr":"银都中路66号","cp":"NavInfo","distance":"76.699611","name":"银都宾馆","poiType":"旅店,宾馆","point":{"x":"13407537.350000","y":"3550351.380000"},"tel":"(0573)88416555","uid":"255234b335f607d3cafa5fe4","zip":""},{"addr":"银都中路66号","cp":"NavInfo","distance":"76.699611","name":"金鑫服饰平价超市","poiType":"服装鞋帽,购物","point":{"x":"13407537.350000","y":"3550351.380000"},"tel":"","uid":"ffc7fafd384596412eb90862","zip":""},{"addr":"崇德中路35号","cp":"NavInfo","distance":"83.651867","name":"崇德百货","poiType":"综合商场\/购物中心,购物","point":{"x":"13407696.440000","y":"3550368.480000"},"tel":"","uid":"b0d64f2939342d808afc0608","zip":""},{"addr":"浙江省嘉兴市桐乡市","cp":"NavInfo","distance":"95.774826","name":"卡尼亚珠宝","poiType":"珠宝饰品,购物","point":{"x":"13407533.050000","y":"3550311.850000"},"tel":"","uid":"a9699f0c58ee9582611c6762","zip":""},{"addr":"桐乡市崇福东路附近","cp":"mix","distance":"95.868714","name":"乔丹专卖","poiType":"服装鞋帽,购物","point":{"x":"13407694.850000","y":"3550414.480000"},"tel":"","uid":"8c539cf8a9cfa740ca09f08f","zip":""}]},"result":{"callback":"BMap._rd._cbk30352","dis_poi":"100","error":0,"ie":"utf-8","little_capacity":[],"oue":"2","poi_num":"10","qt":"rgc","res":"api","type":44,"x":"13407612.87","y":"3550364.78"}})

http://www.bcagps.com/map/json/AddressBMap.ashx?lat=30.52953&lon=120.43016

周边最近的POI查询并且解析出中文地址

var map = new BMap.Map("map");

map.centerAndZoom(new BMap.Point(116.404, 39.915), 16);

map.enableScrollWheelZoom();

var geocoder = new BMap.Geocoder();

var locationOptions = {

poiRadius: 1500,

numPois :2

}

map.addEventListener("click", function(e){

var pt = e.point;

geocoder.getLocation(pt, function(result){

if (result){

var description = result.address;

if (result.surroundingPois[0]){

var poi = result.surroundingPois[0];

description += ". " +

poi.title + "向" + getDirDescription(result.point, poi.point) + " " +

Math.round(map.getDistance(result.point, poi.point)) + "米. "

}

if (result.surroundingPois[1]){

var poi = result.surroundingPois[1];

description += "" +

poi.title + "向" + getDirDescription(result.point, poi.point) + " " +

Math.round(map.getDistance(result.point, poi.point)) + "米."

}

alert(description);

alert("\u53cc\u67aa\u7af9\u6728(\u516c\u53f8\u4f01\u4e1a),\u7af9\u6625\u5802\u5927\u836f\u623f(\u836f\u5e97\/\u836f\u623f,\u533b\u7597)");

}

}, locationOptions)

});

/**

* 获取两点东西南北的位置关系

*/

function getDirDescription(pt1, pt2){

var h = pt1.lng - pt2.lng;

var v = pt1.lat - pt2.lat;

if (Math.abs(h) > Math.abs(v)){

if (h < 0){

return "西";

}

else {

return "东";

}

}

else {

if (v < 0){

return "南";

}

else {

return "北";

}

}

}

分享到:

18e900b8666ce6f233d25ec02f95ee59.png

72dd548719f0ace4d5f9bca64e1d7715.png

2012-01-20 15:46

浏览 3559

评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值