setVisible(false) not applied for labels #25

Open
Sunsvision opened this Issue Jun 25, 2015 · 3 comments

Projects

None yet

3 participants

@Sunsvision

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

@jakeholland

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

@Sunsvision

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.

@b0jan
b0jan commented Mar 17, 2016

This needs a proper fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment