views:

8

answers:

0

Hi guys,

I'm using the jQuery plugin http://googlemaps.mayzes.org/ for Google Maps but have had trouble adding markers.

Current setup:

Show AJAX content in a thickbox, where a map is loaded. The map loads fine, and centers properly to a geocoded address.

However, if you add a marker with a geocoded address the Google Maps API errors out with "a is undefined"

(relevant code from the plugin)

  if ( markers[i].geocode ) {
    var geocoder = new GClientGeocoder();
    geocoder.getLatLng(markers[i].geocode, function(center) {                    
      if (!center) 
        alert(address + " not found");
      else 
        jQuery.googleMaps.marker[i] = new GMarker(center, {draggable: markers[i].draggable, icon: gIcon});
    });
  }

The notable part is geocoder.getLatLng(markers[i].geocode, func... as this is directly calling the maps API, and upon inspection, markers[i].geocode is coming out as my test address ("Australia").

What I'm finding is that if I load the map the first time, it will center the map, but error due to the marker (and not show the UI either). If I close the thickbox and load it up again with a different address/country, the map will load fine, with the UI and centered on the new location with a marker in the old address/country.

Closing and opening the thickbox multiple times after this will move the centering, but the marker will always stay in the first address/country.

Any ideas?