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 635 forks source link

Nested markers: removing data from $scope.markers does not remove markers? #1050

Open 9662 opened 8 years ago

9662 commented 8 years ago

It appears that when using nested markers, the directive falls out of sync with the source markers object.

In other words, if I populate markers via:

angular.extend($scope, {
    markers: {
        layerA: {
            markerA1: { ... }
            ...
        },
        layerB: {
            markerB1: {... }
            ...
        }
});

And then I do a delete $scope.markers.layerA, the data disappears from $scope.markers, as you would expect, but not from .getLayers() (as you would also expect).

Please take a look at test.html for a working example (sorry, I haven't got the hang of those code snippet websites). If you click on the "Dump markers" button, then on "Remove blue", then "Dump markers" again, this is what you get:

getMarkers() test.html:116:5
Object { blue: Object, red: Object } test.html:117:5
$scope.markers test.html:119:5
Object { blue: Object, red: Object } test.html:120:5
Removed blue test.html:126:4
getMarkers() test.html:116:5
Object { blue: Object, red: Object } test.html:117:5
$scope.markers test.html:119:5
Object { red: Object } test.html:120:5