Php 谷歌地图地址和地图显示(超限图片)

Php 谷歌地图地址和地图显示(超限图片),php,google-maps,web,map,geolocation,Php,Google Maps,Web,Map,Geolocation,我有以下问题。我正在使用php中的谷歌地图来获取纬度和经度的地址以及这个位置的地图快照 要获取地址,我使用以下代码: // INITIALIZING CURL $returnValue = NULL; $ch = curl_init(); // SERVICE CALL $url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=".$lat.",".$lon."&sensor=false"; // SETTING

我有以下问题。我正在使用php中的谷歌地图来获取纬度和经度的地址以及这个位置的地图快照

要获取地址,我使用以下代码:

// INITIALIZING CURL
$returnValue = NULL;
$ch = curl_init();

// SERVICE CALL
$url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=".$lat.",".$lon."&sensor=false";

// SETTING PARAMS OF CURL
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

// GETTING AND RESULTING RESULT
$result_part = curl_exec($ch);
$json = json_decode($result_part, TRUE);
我将获得的JSON解析如下:

// PARSING RESULTS FROM JSON
if (isset($json['results'])) {
    foreach    ($json['results'] as $result_part) {
        foreach ($result_part['address_components'] as $address_component) {
            $types = $address_component['types'];
            // GETTING STREET
            if (in_array('route', $types)) {
                $addr = $address_component['long_name'];
            }
            // GETTING STREET NUMBER
            if (in_array('street_number', $types)) {
                $number = $address_component['long_name'];
            }
            // GETTING COUNTRY
            if (in_array('country', $types)) {
                $country = $address_component['long_name'];
            }
            // GETTING POSTAL CODE
            if (in_array('postal_code', $types)) {
                $postal_code = $address_component['long_name'];
            }
            // GETTING CITY
            if (in_array('locality', $types)) {
                $city = $address_component['long_name'];
            }
        }
    }
}
它工作正常,但有时无法获取地址。这看起来像是超负荷的请求,但我不明白为什么,因为我正在编程的网站还不能被其他人访问

与此相关的另一个问题是地图快照。代码如下:

<? echo "<a href = \"https://maps.google.com/maps?q=".$lat.",".$lon."\" target=\"_blank\">" ?>
<? echo "<img src=\"http://maps.googleapis.com/maps/api/staticmap?center=" . $lat . "," . $lon . "&zoom=16&size=200x200&markers=color:blue%7Clabel:I%7C" . $lat . "," . $lon . "&sensor=false\" alt=\"google maps\" width=\"200\" height=\"200\" /></a>" ?>

这也很好,但有时我会得到这样的图像:

我怀疑我超出了限制


有什么想法吗?谢谢您的回答。

正如@geocodezip所建议的,这可能是因为没有使用密钥

此外,根据反向地理编码文件:

注:反向地理编码是一种估计。地理编码器将尝试在一定公差范围内找到最近的可寻址位置;如果没有找到匹配项,地理编码器将返回零结果


`我怀疑我超出了限制。有什么想法吗?`这是在共享网络主机(如RackSpace)上吗?不,不是在这样的共享网络主机上。它位于自己的web服务器上,但该web也用于公司的网页。谷歌是否可能通过一个IP控制该公司所有人员的访问?我指的是,有一整群用户连接到那台IPand上,但它却因为太多的请求而阻止了地图服务?也就是说。看起来你没有在使用它