【发布时间】:2011-12-10 05:11:54
【问题描述】:
我在使用 jQuery 和对 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 无关。
标签: javascript jquery arrays json filtering