【发布时间】:2018-10-25 05:56:43
【问题描述】:
我想根据基于多选下拉菜单中的选择创建的对象过滤我的 GeoJSON 数据。
GeoJSON 数据
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [ -115.55783329999998,32.9646667 ]
},
"properties": { "magType":"mb", "type":"earthquake","horizontalError":0.32,"depthError":0.58, "city":"Brawley", "state":"California", "country":"US"}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [ -115.54583329999998,32.98 ]
},
"properties": { "magType":"mb", "type":"earthquake", "horizontalError":0.24, "depthError":0.46, "city":"Brawley", "state":"California", "country":"US"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [ -118.13383329999999,33.777333299999995 ]
},
"properties": {"magType":"ml","type":"earthquake","horizontalError":0.77,"depthError":0.9, "city":"Brawley","state":"California","country":"US"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [ -115.555,32.967 ]
},
"properties": {"magType":"ml","type":"earthquake", "horizontalError":0.43, "depthError":0.67, "city":"Isangel","state":"Tafea","country":"VU"
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [ -115.55216670000001,32.9658333 ]
},
"properties": {"magType":"mw","type":"tsunami", "horizontalError":0.79, "depthError":1.35, "city":"Zaybak", "state":"Badakhshan", "country":"AF"
}
},
选中值的对象:
sel_data_category = {country:['US','AF'], city: ['Brawley','Zaybak'], magType:['mw']}
sel_data_quant ={horizontalError:[0.68,0.90]}
我想根据这些选定的值过滤数据。所以预期的输出应该是 -
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [ -115.55216670000001,32.9658333 ]
},
"properties": {"magType":"mw","type":"tsunami", "horizontalError":0.79, "depthError":1.35, "city":"Zaybak", "state":"Badakhshan", "country":"AF"
}
}
有什么办法可以做到吗?
编辑:错过了一个水平错误值
【问题讨论】:
标签: javascript json d3.js filter geojson