On Sep 8, 9:42 pm, Nihar <[email protected]> wrote: > Hello guys, > > I'm facing a strange problem..
Not very strange. You need to read the documentation for the map "click" event handler... > Simply created a map, and added an > event handler to place markers on click with an infowindow.. Now. when > I click on the map, the marker is placed, which is fine, but when I > click on that marker, i see this error (though the infowindow pops out > correctly) > > a is > undefinedhttp://maps.gstatic.com/intl/en_ALL/mapfiles/164e/maps2.api/main.js > Line 1119 > > here is a test map.http://www.hostsfx.net/test/map.html > GEvent.addListener(map,'click', function(overlay, latlng){ var marker = new GMarker(latlng, {draggable:true}); GEvent.addListener(marker,'click',function(latlng){ marker.openInfoWindowHtml("I'm a marker"); }); map.addOverlay(marker); }); http://code.google.com/apis/maps/documentation/reference.html#GMap2.click click(overlay:GOverlay, latlng:GLatLng, overlaylatlng:GLatLng) The first click is on the map, there are no overlays so the first argument is null and the second contains a GLatLng. The second click (on the marker) is on an overlay (the marker) so the first argument contains a reference to the marker (which you ignore and the second (the only one you use) is null. Since null doesn't have a lat method, you get an error. -- Larry --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-maps-api?hl=en -~----------~----~----~----~------~----~------~--~---
