更新了一个JSFIDDLE 链接
我正在使用 LeafletJS 构建带有时间轴滑块的网络地图。我正在使用LeafletSlider插件显示一组基于名为的 GEOJSON 属性的标记DATE_START
。这是我的数据对象的示例:
var camps = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": {
"STATUS": "UNOCCUPIED",
"DATE_START": "2015-06-23",
"DATE_CLOSED": "2016-01-23"
},
"geometry": {
"type": "Point",
"coordinates": [64.6875, 34.97600151317591]
}
}, {
"type": "Feature",
"properties": {
"STATUS": "OCCUPIED",
"DATE_START": "2014-01-21",
"DATE_CLOSED": "2015-05-25"
},
"geometry": {
"type": "Point",
"coordinates": [65.335693359375, 36.26199220445664]
}
}, {
"type": "Feature",
"properties": {
"STATUS": "UNOCCUPIED",
"DATE_START": "2015-09-13",
"DATE_CLOSED": ""
},
"geometry": {
"type": "Point",
"coordinates": [67.587890625, 35.969115075774845]
}
}]
};
我的代码示例:
//Create a marker layer (in the example done via a GeoJSON FeatureCollection)
var testlayer = L.geoJson(camps, {
onEachFeature: function(feature, layer) {
layer.bindPopup(feature.properties.DATE_START);
}
});
var sliderControl = L.control.sliderControl({
position: "topright",
layer: testlayer,
timeAttribute: 'DATE_START'
});
//Make sure to add the slider to the map ;-)
map.addControl(sliderControl);
//And initialize the slider
sliderControl.startSlider();
我已将时间滑块插件添加到我的地图中,尽管它可以正常工作,但我似乎无法让滑块按时间顺序显示标记。例如,标记为DATE_START
的价值2014-01-21
第二个显示,而实际上它应该首先显示,因为它是具有最早日期的标记。
如何让我的时间滑块/标记以从最早到最晚的正确顺序显示?谢谢。