scottdejonge / map-icons

An icon font for use with Google Maps API and Google Places API using SVG markers and icon labels
http://map-icons.com/
MIT License
1.05k stars 198 forks source link

setVisible(false) not applied for labels #25

Open Sunsvision opened 9 years ago

Sunsvision commented 9 years ago

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

jakeholland commented 8 years ago

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

Sunsvision commented 8 years ago

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.

bojanvidanovic commented 8 years ago

This needs a proper fix.