Sam Creamer
Sam Creamer

Reputation: 5361

Google Map click event outside polygon

I've looked around and realized that I can define a polygon, and have a click event that only happens when a user clicks within the polygon like this:

polygonClick = google.maps.event.addListener( polygon, "click", function( evt ) {
    function();
} );

What I would like to do is to have a listener that listens everywhere OTHER than inside the polygon, something like this:

polygonClick = google.maps.event.addListener( !polygon, "click", function( evt ) {
    function();
} );

Is this possible? Thanks

Upvotes: 1

Views: 926

Answers (1)

geocodezip
geocodezip

Reputation: 161324

Create a listener on the map.

mapClick = google.maps.event.addListener( map, "click", function( evt ) {
    function();
} );

Upvotes: 4

Related Questions