Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Leaflet popup with angular js

I've a map that's created with leafletjs. The map has some markers that are like this ev124, ev125 etc.

And there are links that has an attribute called key like <a ng-click="popup(evsi)" key="124">link</a>

I'm using angular for this so i can get my key value by using

$scope.popup= function(evsi){
   var key = evsi.key;
}

Now I have to trigger the click event which is a bultin method for leaflet called openpopup();

$scope.popup= function(evsi){
       var key = evsi.key;
       var maker = "ev" + key;
       maker.openpopup();
    }

However this is not working and gives me an error, Object eve124 has no method 'openpopup'

How can I fix this? I'm new to angular. Thanks

like image 872
rksh Avatar asked Sep 10 '26 10:09

rksh


1 Answers

Have you looked at the events raised when a marker is clicked on? See http://tombatossals.github.io/angular-leaflet-directive/#!/examples/events

Also, you might want to check this post out How to use Angular directives ng-click and ng-class inside Leaflet marker popup if you want to do something more clever.

like image 144
mstreffo Avatar answered Sep 12 '26 22:09

mstreffo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!