Angular marker clusterer does not refresh on marker hide
Asked Answered
K

0

7

I've created a plunker for showing this behavior, basically what I've done is to take the demo example from angular maps, and change it just a bit to hide 5 markers every time a marker on the map is clicked. The markers are indeed hidden, but the clusterer never changes. Now here is the strange part, if you drag the map a bit, it will update the clusterer correctly, but it does not refresh automatically.

The onclick event

$scope.clickHandler = function(e) {
    var count = $scope.randomMarkers.length;
    var hidden = 0;
    for (var i = 0; i < count; i++) {
        var oneModel = $scope.randomMarkers[i];
        if (oneModel.options.visible) {
           console.log("hiding: " + oneModel.latitude);
           oneModel.options.visible = false;
           hidden++;
           if (hidden == 5) break;
        }
    }
}

and the marker definition

var ret = {
    latitude: latitude,
    longitude: longitude,
    title: 'm' + i,
    events: {
      click: $scope.clickHandler
    },
    options: {
      visible: true
    }
  };

are the only real differences from the example (aside for telling the markers directive to actually use the marker model options property.

Kasandrakasevich answered 20/4, 2015 at 10:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.