LeafletSlider
LeafletSlider copied to clipboard
The time data is not sorted, and I tried to sort the markers after addControl, it is not working as well.
Hi, I try to use the leadletslider for the markers based on time. The marker_list is a list of the markers like
L.marker(latlng, { time: feature.properties.time, icon: treeIcon });
I tried to sorted the marker_list based on the time, but once passed into the layerGroup, the seq is not persistent.
var layerGroup = L.layerGroup(marker_list);
var sliderControl = L.control.sliderControl({
position: 'sliderright',
timeAttribute: "time",
layer: layerGroup,
range: true,
timeStrLength: 22,
showAllOnStart:true
});
mymap.addControl(sliderControl);
sliderControl.options.markers.sort(function(a, b) {
return (a.feature.properties.time > b.feature.properties.time);
});
sliderControl.startSlider();
I also try the method others recommended to sort the markers after addControl, and the slider is still not in time order, how can I fix it? Thanks