I am using Mapbox GL JS to display a polygon layer. I would allow the user to select a name from the drop-down list, and then select and scale the corresponding polygon.
I already know how to select a matching polygon with map.setFilter
, but I don't know how to zoom in to the corresponding polygons. This is my current code:
map.addLayer({
'id': 'polygon_hover',
'source': 'mysource',
'source-layer': 'mylayer',
'type': 'fill',
'paint': {
'fill-color': 'red',
"fill-opacity": 0.6
},
"filter": ["==", 'CUSTNAME', ""]
});
custname.on("change", function(e) {
map.setFilter('polygon_hover', ["==", 'CUSTNAME', name]);
});
I examined the Mapbox window binding example , but it assumes that you already know what borders are.
Is there a way to get the polygon borders matching the map filter in Mapbox?
source
share