php 通过文字地址获取精、纬度 (复制可用)

IT-Pony 2016-03-31 AM 463℃ 0条
$address = file_get_contents('http://api.map.baidu.com/geocoder/v2/?ak=deQAYBEbexfxn5VAkE4ml4K8teEGOjG9&callback=renderOption&output=json&address='.$_GET['address']);

$address = str_replace(')','',str_replace('renderOption&&renderOption(','',$address));

$address = json_decode($address,true);
//lat = 纬度值; lng=经度值;
$address = $address['result']['location'];

print_r($address);
标签: php

非特殊说明,本博所有文章均为博主原创。

评论啦~