Foxtable(狐表)用户栏目专家坐堂 → 如果通过坐标数据获取百度地图中的地址


  共有3557人关注过本帖树形打印复制链接

主题:如果通过坐标数据获取百度地图中的地址

帅哥哟,离线,有人找我吗?
大红袍
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/7/31 16:37:00 [显示全部帖子]

mark 百度地图Api

 

参考文档 http://developer.baidu.com/map/index.php?title=webapi/guide/webservice-geocoding

 

你去申请成为开发者,红色的替换成你自己key

 

http://api.map.baidu.com/geocoder/v2/?ak=hAaa2NLELKdAIfMhMjnuEgi1&output=json&location=39.91064,116.39925

 

做个简单的例子,如下

 

dim 纬度 as double = 39.91064
dim 经度  as double = 116.39925

Dim rqst As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://api.map.baidu.com/geocoder/v2/?ak=hAaa2NLELKdAIfMhMjnuEgi1&output=json&location=" & 纬度 & "," & 经度)
Dim rsps As System.Net.HttpWebResponse = rqst.GetResponse
Dim stm As System.IO.Stream = rsps.GetResponseStream()
Dim reader As New System.IO.StreamReader(stm)
Dim json As String = reader.ReadToEnd
msgbox(json)
Dim ScriptControl As Object, data  As Object, JscriptCode As String
JscriptCode = "function toObject(json) {eval(""var o=""+json);return o;}"
ScriptControl = CreateObject("MSScriptControl.ScriptControl")
With ScriptControl
    .Language = "Javascript"
    .Timeout = -1
    .AddCode(JscriptCode)
    data = .Run("toObject", json)
End With

msgbox(data.status)
msgbox(data.result.formatted_address)


 回到顶部