2011-07-20 9 views
3

最近、Google Maps APIからオーバージングリミットのステータス応答が1つのジオコーディング要求を送信し始めました。なぜこれが起こっているのか本当に混乱していますか?私は間違いなく、1日のリクエストの上限2,500に達する近くに来なかった。 、私は単に私の要求を投稿した場合(http://maps.googleapis.com/maps/api/geocode/json?address=1125+First+Avenue,New +ニューヨーク、NY &センサー= falseをGoogleマップV3 API - クエリの制限を超えていますが、リクエストは1つだけです

も)それはうまく動作し、私は適切な応答を得るブラウザには、

誰もが考えていただければ幸いです。

答えて

18

これは、リクエストに私のホスティングプロバイダ(ラックスペース)のipsを使用しているため、私はPHPコードの一部としてリクエストを持っているためです。他の人々がやっていること。

これを回避するための解決策は、クライアント側からjavascriptを使用してリクエストを送信することです。そのため、ユーザーのブラウザや現在使用しているIPによって処理されます。

解決策が他の人を助けることを望みます。

3

PHPからリクエストを送信するときに、リクエストはサーバーIPから送信され、Googleでは1つのIPに対する制限付きのリクエストが許可されるため、ユーザーのIPからリクエストを送信する方が良いでしょう。あなたは以下のJavaScript関数を使用してそれを行うことができます。

function display_map(address_str,business_name,phone_number,google_local_pages){ 

var address = address_str; 

// Create a new Geocoder 
var geocoder = new google.maps.Geocoder(); 

// Locate the address using the Geocoder. 
    geocoder.geocode({ "address": address }, function(results, status) { 

     // If the Geocoding was successful 
     if (status == google.maps.GeocoderStatus.OK) { 

      var latlang = results[0].geometry.location; 
    //  alert(latlang); 

     // Create a Google Map at the latitude/longitude returned by the Geocoder. 
     var myOptions = { 
      zoom: 16, 
      center: results[0].geometry.location, 
      mapTypeId: google.maps.MapTypeId.ROADMAP 
     }; 
     var map = new google.maps.Map(document.getElementById("map"), myOptions); 

     // Add a marker at the address. 
     var marker = new google.maps.Marker({ 
      map: map, 
      position: results[0].geometry.location 
     }); 

    // var data = "<div id='top'><span>"+business_name+"</span><a href='"+google_local_pages+"'>More Info</a><div id='address'>"+address_str+"</div></div>"; 

     var infowindow = new google.maps.InfoWindow({ 
     content: "<div id='top' style='height:175px;width:200px;'><span id='bname' style='font-size: 1.3em;font-weight:bold;'>"+business_name+':'+"</span><a style='text-decoration: none;' target='_blank' href='"+google_local_pages+"'>More Info</a><hr/><div id='address' style='font-size: 1em;font-weight:normal;align:left'>"+address_str+"</div><hr/><div id='lower'><a style='text-decoration: none;' target='blank' href='http://maps.google.com/maps?saddr=&daddr="+address_str+"'"+">Directions</a>&emsp;<a style='text-decoration: none;' href='javascript:void(0);' onclick='showform();'>Search Nearby</a><div style='display:none;' id='hiddenForm'><hr><span style='font-size: 1em;font-weight:bold;'>Search Nearby:</span><form action='http://maps.google.com/maps' method='get' target='_blank'><input type='text' name='q' id='q' value='' size='12' /><input type='submit' value='GO'/>&emsp;<span phv='&quot;%1$s&quot;' style='font-size: 0.7em;font-weight: small;'>e.g.,&ldquo;pizza&ldquo;</span><input type='hidden' name='near' value='"+address_str+"'/></form></div></div>" 
     }); 

     google.maps.event.addListener(marker, 'click', function() { 
     infowindow.open(map, marker); 
      }); 

     } else { 
     try { 
      console.error("Geocode was not successful for the following reason: " + status); 
     } catch(e) {} 
     } 
    }); 
} 
関連する問題