百度API获取经纬度使用

时间:2021-08-24 19:14:16

首先通过百度地图,注册账号,然后申请密钥

http://lbsyun.baidu.com/apiconsole/key

搜索某个关键字

http://api.map.baidu.com/place/v2/search?q=大族广场&region=北京&output=json&ak={你的密钥}

{
"status":0,
"message":"ok",
"results":[
{
"name":"大族广场购物中心",
"location":{
"lat":39.799477,
"lng":116.51888
},
"address":"北京经济技术开发区荣华南路2号(荣京东街地铁站)",
"street_id":"a83773e6a072a421aecb6633",
"telephone":"010-53876696",
"detail":1,
"uid":"a83773e6a072a421aecb6633"
},
{
"name":"洪泰大族创新空间",
"location":{
"lat":39.798849,
"lng":116.519311
},
"address":"北京经济技术开发区荣华南路2号大族广场T5六层荣京东街地铁站B1口直行32米",
"detail":1,
"uid":"876ddd7ad4cbbd68a20464c4"
},
{
"name":"北京亦网科技有限公司",
"location":{
"lat":39.794674,
"lng":116.521058
},
"address":"北京市经济技术开发区大族广场T5座1101室",
"street_id":"9aaf3f2df2c2c5cd59bbbc2e",
"detail":1,
"uid":"9aaf3f2df2c2c5cd59bbbc2e"
}
]
}

通过搜索的结果,查询一些具体信息

http://api.map.baidu.com/place/v2/detail?uid=a83773e6a072a421aecb6633&output=json&scope=2&ak={你的密钥}

{
"status":0,
"message":"ok",
"result":{
"name":"大族广场购物中心",
"location":{
"lng":116.51887970808,
"lat":39.799476946374
},
"address":"北京经济技术开发区荣华南路2号(荣京东街地铁站)",
"telephone":"010-53876696",
"detail":1,
"uid":"a83773e6a072a421aecb6633",
"street_id":"a83773e6a072a421aecb6633",
"detail_info":{
"tag":"购物;购物中心",
"detail_url":"http://api.map.baidu.com/place/detail?uid=a83773e6a072a421aecb6633&output=html&source=placeapi_v2",
"type":"shopping",
"price":"0",
"overall_rating":"3.4",
"service_rating":"0",
"environment_rating":"0",
"image_num":"2",
"comment_num":"5"
}
}
}

更多具体的参数使用,参照API

http://lbsyun.baidu.com/index.php?title=webapi/guide/webservice-placeapi