angular-ui / ui-leaflet

AngularJS directive to embed an interact with maps managed by Leaflet library
http://angular-ui.github.io/ui-leaflet
Other
315 stars 137 forks source link

Supporting public methods from label plugin #51

Open nmccready opened 8 years ago

nmccready commented 8 years ago

From @fbrandel on February 14, 2015 13:5

The Leaflet.label plugin seems to be supported when creating markers in the directive or even when the label message gets changed. So far so good. Now I wonder if/how it is possible to access the label with its public methods like showLabel() or hideLabel().

This does not seem to work, as once the marker is created, I do not have access to the 'real' L.Marker instance.

Do you have any advice on this?

Thanks.

Copied from original issue: tombatossals/angular-leaflet-directive#632

nmccready commented 8 years ago

From @seadour on March 5, 2015 20:26

Hi fbrandel,

Have you tried using the leafletData service to access the map object?

See related comment here: https://github.com/tombatossals/angular-leaflet-directive/issues/184#issuecomment-28553932

Inject the service into your controller, then try something like:

leafletData.getMap().then(function(map) {
    map.Marker.showLabel();
});