0

I am using Mapboxgl style to show my map and I need to set minzoom on features on a layer based on their calculated area attribute. For instance a derived and briefed tiny example from a layer below:

{ "type": "FeatureCollection", "name": "water", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, "features": [ { "type": "Feature", "properties": { "class": "water", "name": "Lake", "area": 116068.2 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 119.14096, -33.3257293 ], [ 119.141042, -33.3258274 ], //and more coordinates ] ] ] } }, { "type": "Feature", "properties": { "class": "water", "name": "Lake Eucumbene", "area": 245452452.452 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 130.14096, -33.3257293 ], [ 140.141042, -33.3258274 ], //and more coordinates ] ] } } ] }

My goal is to show symbols of features when map is zoomed-in and polygons are big enough. As there are thousands of polygons I am not able to distribute them onto different layers and I guess it's a bit clunky and obsolete way of treating.

I have tried to apply interpolation calculation on minzoom:

"minzoom":[ "let", "area", [ "get", "area" ], [ "interpolate", [ "linear" ], [ "zoom" ], 1, [ "interpolate", [ "linear" ], [ "var", "area" ], 116068.2, [ 5 ], 245452452.452, [ 1 ] ] ] ]

but I will get an error of Number expected, found an array.

Are there any other possibilities to achieve my goal for example somehow to set visibility of 0 or 1 on the features based on their area size or am I doing anything wrong?? Thanks

herco0l
  • 11
  • 2

0 Answers0