View Full Version : Limited number of results (Google maps API)

07-16-2009, 02:58 PM

I'm trying to use google maps for the web application I'm developping. The idea is I have a database with all the universities with whom we exchange. I know where each university is (city). What I want to do is show all the cities on a google map (as markers)
Here is the code I am using:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
<title>Trouver une université d'accueil</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAyddaCMLynA_00r_M38R_TRQj6Z6VgkTRnHSQUsYiDp309FxmwxR9eUK5cyGOtQg8LSks6PIr0kmeUw" type="text/javascript"></script>
<script type="text/javascript">
var map;
var villes = new Array
"Albuquerque, NM",
"Buenos Aires",
"Champs-sur-Marne ",
"Chapel Hill",
"Hong Kong",
"Insurgentes Mixcoac",
"Paris (Palaiseau)",
"Rio de Janeiro",
"San Diego, CA",
"Vaulx en Velin",
/* 73 cities */

// On page load, call this function
function load()
var geocoder;
// Create new map object
map = new GMap2(document.getElementById("map"));

// Create new geocoding object
geocoder = new GClientGeocoder();

// Retrieve location information, pass it to addToMap()
var villesLength = villes.length;
for(var i = 0; i < villesLength; ++i)
geocoder.getLocations(villes[i], addToMap);
//Center the map
/*Add controls: Zoom controls, Type Controls,
Add event listeners: Scroll event*/
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(40, 0), 0);

// This function adds the point to the map
function addToMap(response)
if(!response || response.Status.code != 200)
// Retrieve the object
place = response.Placemark[0];

// Retrieve the latitude and longitude
point = new GLatLng(place.Point.coordinates[1],

// Create a marker
var marker = new GMarker(point);
GEvent.addListener(marker, "click",
window.onload = load;
window.onunload = GUnload();
<div id="map" style="width: 800px; height: 600px;"></div>

The code works well, it finds the cities and places a marker at the appropriate place. BUT, only 18 out of the 73 cities are shown. If I take away some cities from the list, the others are found. All the cities can be found this way, but only up to 18 appear at a time.

Does anyone know how to avoid having this limit?

Thank you very much.

07-16-2009, 10:19 PM
If there's not a problem with the #19th entry, then it could be you hit a 'geocoding' limit that I believe Google said they would repair in the near future.

07-17-2009, 02:12 PM
Well it turns out that I was making too many requests in a too short time period of time. What I'm doing now is testing whether the "too many requests error" occurs and, if so, try again.

Works like a charm

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum