How To Use A Google Map Event Listener To Pass A Variable And Submit A Form
I'm following a Google Maps v3 demo gallery example here, which is a rectangle overlay. I modified the rectangle to make it clickable. rectangle = new google.maps.Rectangle({ m
Solution 1:
This won't do what you expect (and it is missing a closing ")", is that a typo?):
google.maps.event.addListener(rectangle, 'click', editSite(22);
the "editSite" without the arguments is a function pointer (in your "working" code):
google.maps.event.addListener(rectangle, 'click', editSite);
if you add an argument, it gets executed immediately and the return value is used as the function to be executed when the event occurs (not what you want in this case). If you want to call a named function with an argument, wrap it in an anonymous function:
google.maps.event.addListener(rectangle, 'click', function() {
editSite(22);
});
Post a Comment for "How To Use A Google Map Event Listener To Pass A Variable And Submit A Form"