map-icons icon indicating copy to clipboard operation
map-icons copied to clipboard

setVisible(false) not applied for labels

Open Sunsvision opened this issue 9 years ago • 3 comments

Hi! When i try to hide markers using default marker.setVisible(false) function - markers are hidden but labels still shown on the map

Sunsvision avatar Jun 25 '15 16:06 Sunsvision

I have the same issue, did you find a workaround?

jakeholland avatar Jul 24 '15 15:07 jakeholland

I have different types of markers, so init them in this way:

...
var labelClass = 'some_class_name';
var labelHTML = '<i class="' + labelClass + '"></i>';
var marker = new Marker({
    map: appMap,
    position: place.geometry.location,
    zIndex: 9,
    icon: {
        path: SQUARE_PIN
    },
    label: labelHTML
});

Then add zoom handlers:

...
google.maps.event.addListener(appMap, 'zoom_changed', function() {
    setTimeout(function() {
        if (markersAreHidden) { // special flag 
            $('#myMap').find('.' + labelClass).parent().hide();    
        }
    }, 100);
});

Not the most elegant solution but it works for now.

Sunsvision avatar Jul 24 '15 15:07 Sunsvision

This needs a proper fix.

bojanvidanovic avatar Mar 17 '16 13:03 bojanvidanovic