user1271518
user1271518

Reputation: 636

overlay above markers that won't allow clicking the markers beneath it , google maps api v3

I've added an OverlayView to the map. I have a lot of different markers on map. I allow clicking drawn objects on the canvas, but i don't want to allow clicking any shape / marker on the map while the overlay object's enabled property it true.

How can i do that? without keeping track of ALL the markers/ shapes/ (could be a lot!) and then running on each of them , removing the click listener and at the end adding it..

Thanks

Upvotes: 2

Views: 292

Answers (1)

Rob
Rob

Reputation: 156

Create a variable overlayEnabled and update it every time you enable/disable the overlay. Then in your click listeners, check that variable before performing any action.

google.maps.event.addListener(marker, 'click', function(e) {
    if(overlayEnabled) {
        // perform action
    } else {
        // do nothing
    }
});

Upvotes: 1

Related Questions