Hacktivista Hacktivista - 5 months ago 60
AngularJS Question

Angular-leaflet-directive: Open popup on drop

I'm trying to open popup on drop, but it does not work, I've tried with

$scope.$on('leafletDirectiveMarker.dragend', function(event,args){
args.model.focus = true;
});


and

$scope.$on('leafletDirectiveMarker.dragend', function(event,args){
$scope.markers.forEach(function(marker){
marker.focus = false;
});
args.model.focus = true;
});


But popup does not open until I drag and drop the marker for second time.
Here how this should work

That's not how it should work, how can I achieve this?

iH8 iH8
Answer

Use L.Marker's openPopup method:

Opens the popup previously bound by the bindPopup method.

http://leafletjs.com/reference.html#marker-openpopup

$scope.$on('leafletDirectiveMarker.dragend', function(event,args){
    // Marker which fires the event is stored in args.leafletObject
    args.leafletObject.openPopup();
});