从 php 中的经纬度获取地区名称
Get district name from latitude and longitude in php
我有当前的纬度和经度,如何在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_address;
?>
这将获得完整的地址,因为您只是在 url
中传递了很长时间
注意: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>';
?>
希望对您有所帮助。
我有当前的纬度和经度,如何在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_address;
?>
这将获得完整的地址,因为您只是在 url
中传递了很长时间注意: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>';
?>
希望对您有所帮助。