在php中从经纬度获取地区名称
我有当前的纬度和经度,这是如何在php中获得地区名称或代码。请帮帮我。在php中从经纬度获取地区名称,php,latitude-longitude,Php,Latitude Longitude,我有当前的纬度和经度,这是如何在php中获得地区名称或代码。请帮帮我。 <?php $geocode=file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?latlng=48.283273,14.295041&sensor=false'); $output= json_decode($geocode); echo $output->results[0]->formatted_add
<?php
$geocode=file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?latlng=48.283273,14.295041&sensor=false');
$output= json_decode($geocode);
echo $output->results[0]->formatted_address;
?>
这将获得完整的地址,因为您只需在该url中传递lat long
注意:需要Api密钥 您可以使用
geoplugin
试试这个:
<?php
$geoPlugin_array = unserialize( file_get_contents('http://www.geoplugin.net/php.gp?ip=###.###.###.###') );//Replcae ###.###.###.### with your ip address.
echo '<pre>';
print_r($geoPlugin_array);
echo '</pre>';
?>
希望这能对您有所帮助。谢谢KARAN。它起作用了