Angular - Updating Leopard Heat Map Data

I am using the Angular-Layaflet directive to display a heatmap and I want the data to evolve over time. My code looks like this:

getData().then(function (data) {
    $scope.heat.index = 0;
    $scope.heat.data = data;
    $scope.layers.overlays.heat = {
        name: "Heatmap",
        type: "heat",
        data: $scope.heat.data[$scope.heat.index],  // data is a dictionary, not an array
        visible: true
    };
    $scope.$watch('heat.index', function (new_index) {
        $scope.layers.overlays.heat.data = $scope.heat.data[new_index];
    });
});

      

However, when I change data.index

(via the slider) nothing happens. What can go on? I know Angular-Leaflet supports this behavior due to this Github issue where someone added it.

+3


source to share


1 answer


leafletData.getMap().then(function (map) {
  map.eachLayer(function (layer) {
    if (layer.options.layerName == 'heatmap') {
       layer.setLatLngs(newHeatmapData);
    }
  })
})

      

This worked for me.



Leaflet.heat provides a redraw () method, but that didn't work for me.

0


source







All Articles