如何用百度地图API查询特定地址的精确经纬度坐标?
- 内容介绍
- 相关推荐
本文共计324个文字,预计阅读时间需要2分钟。
通过PHP开发地图功能时,经常会使用到地址经纬度。今天分享如何使用PHP调用百度地图API获取指定地址的经纬度。
phppublic function getLatLng($address='成都', $city='成都'){ $result=array(); $url=http://api.map.baidu.com/geocoder/v3/?address={$address}&city={$city}&output=json&ak=YOUR_BAIDU_API_KEY; $response=file_get_contents($url); $data=json_decode($response, true); if (isset($data['result']['location'])) { $result['lat']=$data['result']['location']['lat']; $result['lng']=$data['result']['location']['lng']; } return $result;}
通过PHP开发地图功能的时候经常会使用到地址经纬度,今天分享如何PHP使用百度地图api获取指定地址的经纬度。
本文共计324个文字,预计阅读时间需要2分钟。
通过PHP开发地图功能时,经常会使用到地址经纬度。今天分享如何使用PHP调用百度地图API获取指定地址的经纬度。
phppublic function getLatLng($address='成都', $city='成都'){ $result=array(); $url=http://api.map.baidu.com/geocoder/v3/?address={$address}&city={$city}&output=json&ak=YOUR_BAIDU_API_KEY; $response=file_get_contents($url); $data=json_decode($response, true); if (isset($data['result']['location'])) { $result['lat']=$data['result']['location']['lat']; $result['lng']=$data['result']['location']['lng']; } return $result;}
通过PHP开发地图功能的时候经常会使用到地址经纬度,今天分享如何PHP使用百度地图api获取指定地址的经纬度。

