微信公众号获取的经纬度为GPS的经纬度,和百度google地图用的经纬度有区别,必须转换一下才能获取正确的经纬度。
$baiduapiurl = "http://api.map.baidu.com/geoconv/v1/?coords={$userdbinfo['lon']},{$userdbinfo['lat']}&from=3&to=5&ak=A1f31379ad5aa6e47617df2dd4e2abfe";
$result = json_decode(file_get_contents($baiduapiurl),ture);//用百度api接口把微信获取的GPS经纬度转换为百度地图经纬度
$toaddres = "http://api.map.baidu.com/geocoder/v2/?ak=A1f31379ad5aa6e47617df2dd4e2abfe&location={$result['result'][0]['y']},{$result['result'][0]['x']}&output=json&pois=1";
$tureaddinfo = json_decode(file_get_contents($toaddres),ture);//根据经纬度获取地图信息