1
votes

I need to get the handle of a marker in order to set the icon when I have a ng-mouseover somewhere else on the page.

I push my markers into leaflet like this:

angular.extend($scope, 
    {markers: 
        {'id1': {lat:foo, lng:bar}, 
         'id2': {lat:foo, lng:bar}, ...
        }
    });

$scope.markers['id1'] returns the correct lat/lng dict. Here, i need the marker object so I can perform a marker.setIcon().

Looked a little into leafletMarkersHelpers but no success ...

Would appreciate any starting point.

Thanx

Best

/B

1

1 Answers

1
votes

There's an leafletData service for that. The Promise you get when you call leafletData.getMarkers() resolves with the Leaflet marker objects in the object with keys like in your scope.

leafletData.getMarkers().then(function (markers) {
    markers.id1.setIcon(...);
});