socib / Leaflet.TimeDimension

Add time dimension capabilities on a Leaflet map.
MIT License
435 stars 139 forks source link

Badly deleted data when changing layers #163

Open thomasBbene opened 5 years ago

thomasBbene commented 5 years ago

Hi,

My project and display geolocation data, I have several 'map' that I display in several baseLayer. At each change of baseLayer I regenerate the creation of my layers. In these layers I have a layer of 'geolocation data'. Which is deleted and recreated each time. But when I go from one layer to another, my data is sometimes present and my time bar at the bottom is not positioned at the beginning but compared to the data of the previous report. Internet help me compared to a lot of bug, but the one remains misunderstood ...

Here is the creation code of the layer:

                LayerData.addData($scope.buildObj);
                $scope.layers.TimeLayer = $window.L.timeDimension.layer.geoJson(LayerData, {
                    updateTimeDimension: true,
                    addlastPoint: true,
                    waitForReady: true
                });

                $scope.layers.TimeLayer.addTo( $scope.mapReport.map );
                addLayerToControl( $scope.layers.TimeLayer, 'TimeLayer' );
        function addLayerToControl ( layer, name ) {
            $scope.control.addOverlay( layer, name );
        }

Here is the code to remove the layer when changing baseLayer :

$scope.mapReport.map.on('baselayerchange', function(layer) {
                            $scope.scaleBar.remove();
                            $scope.basemap = layer.layer.name;
                            _.each($scope.layers, function(l){
                                 $scope.mapReport.map.removeLayer(l);
                                 $scope.control.removeLayer(l);
                            });
                            startRenderingMap($scope.report.data);
});

On my map I'm supposed to display only one tag at a time and I end up with two tags, and my time sliders moved without me wanting it.

First view: image

Second view (i change of baseLayer, he delete and create new data) : image

third view (i return in the first map, look mu cursor) : image

thanks you for you help ! (: