1
我有一個小問題,使用jQuery和排序JSON數組。根據用戶選擇過濾JSON嵌套數組
我正在做的是根據用戶選擇的小時過濾一個geoJSON數組。 用戶可以使用jQuery滑塊選擇一個小時範圍。
$("#slider-range").slider({
stop: function(event, ui) {
$("#amount").val("h" + ui.values[0]+":00" +
"h" + ui.values[1]+":00");
minSel =ui.values[0];
maxSel =ui.values[1];
//HERE SHOULD BE PLACED THE FILTER FUNCTION
filterArray(minSel,maxSel);
}
});
如何能我小時之間選擇僅返回數組值由他們visitedTimes
有序?
下面是這個數組的一個例子。
任何人都可以幫助我嗎?
{ "type": "FeatureCollection", "features": [
{ "type": "Feature",
"id": "...",
"geometry": { "type": "Point", "coordinates": [...]},
"properties": { "venueName": "Its name",
"visitedTimes": "1",
"day": "07",
"month": "09",
"hour": "00",
"min": "50",
"sec": "58"
}
},
{ "type": "Feature",
"id": "4bd34eca462cb7133d1dde07",
"geometry": { "type": "Point", "coordinates": [...]},
"properties": { "venueName": "Old Wild West",
"visitedTimes": "4",
"day": "07",
"month": "09",
"hour": "00",
"min": "51",
"sec": "21"
}
},
{ "type": "Feature",
"id": "...",
"geometry": { "type": "Point", "coordinates": [...]},
"properties": { "venueName": "Past & future",
"day": "07",
"month": "09",
"hour": "00",
"min": "51",
"sec": "23"
}
}
]}
我假設你將解析JSON到一個JavaScript對象,所以你的問題實際上不是JSON相關的。 –