tombatossals / angular-leaflet-directive

AngularJS directive to embed an interact with maps managed by Leaflet library
http://tombatossals.github.io/angular-leaflet-directive
MIT License
1.5k stars 637 forks source link

Marker added event #474

Closed olanod closed 9 years ago

olanod commented 10 years ago

Hello, I'm using div markers with angular bindings but they aren't compiled by angular so the binding doesn't work. So far the only way a I have found to make work the binding is to listen to the leafletDirectiveMap.layeradd and check if e.leafletEvent.layer._icon is defined and then compile the marker myself.
Very ugly if you ask me, besides it doen't work all the time, it seems there is a race condition and its just a coincidence that it works. There should be an event that fires when the marker(and the html) is added or the directive should compile the marker html so we don't have to do it manually from outside.

cleversprocket commented 9 years ago

This would be nice. I found a workaround in @blackjid answer here: https://github.com/tombatossals/angular-leaflet-directive/issues/238

I modified it for use with ng-click bindings in marker popups:

$scope.$on('leafletDirectiveMarker.popupopen', function (event, leafletEvent) {

                var newScope = $scope.$new();

                $compile(leafletEvent.leafletEvent.popup._contentNode)(newScope);
            });
j-r-t commented 9 years ago

Compiling has been around for awhile now and I hopefully fixed some of the odd behaviour in #800 and also @cgat in #813