Geographic Information Systems Asked by nronnei on March 14, 2021
I’ve got a relational dataset broken into two layers: members and organizations. They’re GeoJSON, with features that look something like this:
// Org Features
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-78.34998, 37.784]
},
"properties": {
"id": 46391,
"name": "A Big Organization",
"lifetime_profiles": 7013,
"present_profiles": 49
}
}
// Member Features
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-80.99998, 47.7624]
},
"properties": {
"id": 21446,
"given_name": "John",
"family_name": "Doe",
"orgs": [21437, 117028]
}
}
I want to show which members are linked to which organizations when I click on the map. I’m trying to do so using the following filter:
const handleClick = (target) => {
const bbox = [
[target.point.x - 5, target.point.y - 5],
[target.point.x + 5, target.point.y + 5]
];
const opt = { layers: ['orgs'] };
const targetIDs = map.queryRenderedFeatures(bbox, opt).map((feature) => {
return feature.properties.id;
});
// find clicked orgs
map.setFilter('users', ['in', 'orgs', ...targetIDs]);
};
From my earlier research, I’ve gathered that the "in"
filter is deprecated now. How can I accomplish this aim using current filters?
I guess you're referring to "deprecated syntax" from https://www.mapbox.com/mapbox-gl-js/style-spec/#other-filter ?
I don't really get why it is, because all those filters syntax still works on last MapBox versions. However it seems that "match"
now replace "in"
. From https://github.com/mapbox/mapbox-gl-js/issues/6144:
The match expression provides an equivalent that's almost as concise as "in"
Answered by MaxPlank on March 14, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP