Php 返回错误结果的地理编码器
我在php中使用google geocoder API来获取一个地方的lat和LAGPhp 返回错误结果的地理编码器,php,google-maps,google-geocoder,google-geocoding-api,Php,Google Maps,Google Geocoder,Google Geocoding Api,我在php中使用google geocoder API来获取一个地方的lat和LAG <?php $url = 'http://maps.googleapis.com/maps/api/geocode/json?address=Hollywood,+Newyork,+CA&sensor=true'; $response = file_get_contents($url); $response = json_decode($response, true);
<?php
$url = 'http://maps.googleapis.com/maps/api/geocode/json?address=Hollywood,+Newyork,+CA&sensor=true';
$response = file_get_contents($url);
$response = json_decode($response, true);
$lat = $response['results'][0]['geometry']['location']['lat'];
$long = $response['results'][0]['geometry']['location']['lng'];
echo "latitude: " . $lat . " longitude: " . $long;exit;
?>
其返回的纬度和经度值为34.1408919,-118.350441。但好莱坞在美国佛罗里达州。所以它不应该为我返回任何结果。我将如何实现这一点返回基于您的查询,在本例中:
加利福尼亚州纽约市好莱坞
。
谷歌正在回归lat并渴望美国加利福尼亚州北好莱坞纽约街91602号
如果要查找其他地址,请更改查询