调用百度地图提供的坐标/地址解析,获得对应的地址/坐标,可拓展
调用时需要注册百度并
申请密钥(暂时无限制),然后在程序中代替your_key
第一次使用,发现如果查询不到结果时,返回json中status也是ok,但是result返回为空list,不知为何。
由地址解析坐标时,尽量使用街道的相交路口查询。对于未指定城市而应获得多个结果的情况,实际上获得与无结果一样的输出。暂不知如何解决。
平台 :Python2.7,
Geocoding API
v1.0,windows XP
参考页面:http://developer.baidu.com/map/geocoding-api.htm
1.[文件] test.py ~ 260B 下载(135)
from baidumap import xBaiduMap
bm=xBaiduMap()
print bm.getLocation("红旗大街淮河路",'哈尔滨')
print bm.getLocation("人民路沙浦路")
print bm.getLocation("人民路沙浦路",'广州')
print bm.getAddress(30.690714,104.079473)
2.[文件] baidumap.py ~ 2KB 下载(145)
#-*- coding:utf-8 -*-
import urllib2,urllib,httplib
import json
class xBaiduMap:
def __init__(self,ke