Is there a way of sending multiple addresses to through one geocode request:
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
addMarker(results[0].geometry.location);
var the_string = generate_string(elements, a, address);
infowindow[a] = new google.maps.InfoWindow({
content: the_string
});
google.maps.event.addListener(markersArray[a], "click", function() {
infowindow[a].open(map, markersArray[a]);
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
where address contains an array of addresses. Reason is I am coming across "OVER_QUERY_LIMIT" addressed here OVER_QUERY_LIMIT while using google maps and here Google Map Javascript API v3 - OVER_QUERY_LIMIT Error
I was wondering if i should start using the server side version of the client or continue with the javascript api and get help with sending an array of addresses through the geocoder call?
In your opinion or experience, if i have an application that you can type endless amounts of addresses into fields and then press a "plot to map" button, how would you go about doing this in terms of api calls, geocoding etc?
EDIT:////////////////////////
I'm now using this code:
class geocoder{
static private $url = "http://maps.google.com/maps/api/geocode/json?sensor=false&address=";
static public function getLocation($address){
$url = self::$url.urlencode($address);
$resp_json = self::curl_file_get_contents($url);
$resp = json_decode($resp_json, true);
if($resp['status']='OK'){
return $resp['results'][0]['geometry']['location'];
}else{
return false;
}
}
static private function curl_file_get_contents($URL){
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, $URL);
$contents = curl_exec($c);
curl_close($c);
if ($contents) return $contents;
else return FALSE;
}
}
and calling it like so:
$address = urlencode($field_set["value"]);
$loc = geocoder::getLocation($address);
in a loop of every address being placed in (in this case 20 times).
It only places 10 markers on the map regardless of the loop correctly having 2 different lngs and lats.
It returns null for the last 10 lat lngs :s
EDIT:///////////////////////////
I have placed a sleep in the loop that calls this:
$loc = geocoder::getLocation($address);
every 8th geocoding, it pauses for a second then continues.. this seems to allow all geocoder locations to be rendered correctly... but it seems like a fluff.
Any ideas?