Skip to content Skip to sidebar Skip to footer

Google.maps.event.trigger Not Run When Map Reload

I have a project using Google maps api v3, and I am using google.maps.event.trigger to call or trigger the listener that is created when the map loads. In this case I set listener

Solution 1:

When you take a look into the console after triggering the click you'll see an error:

UncaughtTypeError: Cannot read property 'vertex'ofundefined

This undefined object is a PolyMouseEvent . This object will be passed to the click-callback when a real click occurs. But when you trigger the click programmatically this object is missing, what forces the error above(and somehow stops the binding of the click-listener after re-initializing the map ).

solution: pass an empty object as argument to the click-callback when you trigger the click programmatically:

google.maps.event.trigger(polygon[nomor], "click", {});

Demo: http://jsfiddle.net/doktormolle/jVFN2/

Post a Comment for "Google.maps.event.trigger Not Run When Map Reload"