通过城市经纬度,在百度地图显示(2)

按照上一节的方法,通过百度API获取了相应城市的经纬度,现在更加经纬度,在百度地图上标注出相应城市的位置。

address_html = pd.DataFrame(columns=['content'])#构建新的数据表
In [131]:#形成百度API需要的json
for one_index in address.index:
    address_html.loc[one_index, 'content'] = '{' '"lat":' + str(address.loc[one_index, '纬度']) + ',' +  '"lng":' +  str(address.loc[one_index, '经度']) + ',' + '"quyu":' + str(address.loc[one_index, '固定区域']) + '}' + ','
    #'{' +  '"lat":' + str(address.loc[one_index, '纬度'] + ',' + '"lng":' + str(address.loc[one_index, '经度']) + ',' + '"quyu":' +  str(address.loc[one_index, '固定区域']) +'}' + ','
In [132]:
address_html
Out[132]:
content
0	{"lat":22.792648,"lng":112.943605,"quyu":广东省江门...
1	{"lat":22.785443,"lng":112.952709,"quyu":广东省江门...
2	{"lat":22.80379,"lng":112.945721,"quyu":广东省江门市...
3	{"lat":22.823418,"lng":112.933702,"quyu":广东省江门...
4	{"lat":22.806107,"lng":112.928462,"quyu":广东省江门...
5	{"lat":22.836484,"lng":112.947117,"quyu":广东省江门...
In [136]:#写入文件中
address_html.to_csv(r'C:\Users\Administrator\Desktop\address_html.csv', encoding = 'gbk')

直接在http://developer.baidu.com/map/jsdemo.htm#c1_19,百度官网html例子修改的。显示如下。


借鉴:

https://mp.weixin.qq.com/s?__biz=MjM5MzI5MTQ1Mg==&mid=2247484779&idx=1&sn=3ff7e02d3537fbebad67ad7405b81838&chksm=a69808b891ef81aef80db3e9409860fa8725822a960e3ffbf27485c0dd113cd13fef8aac34c8&mpshare=1&scene=23&srcid=0523BVlow1uDlMGnp88p6Prz#rd

猜你喜欢

转载自blog.csdn.net/weixin_41512727/article/details/80554213