Mapbox minZoom (or maxZoom) based on Expression on Android

34 views Asked by At

I'm using Mapbox Android SDK v.11.1.0.

I create a FillLayer from from a GeoJsonSource, which is fine. Every feature included in the source has a property called "minZoom" with a Double value.

Then, in the fillLayer, I would like to hide/show single features based on the map current zoom level. I thought I could be doing like:

fillLayer("layerId", "sourceId") {
   minZoom(
      get("minZoom")
   )
}

Unfortunately minZoom function in FillLayer doesn't accept an expression, but only a Double value.

Is there any other way to achieve the same result?

Thank you all

UPDATE: I found a working solution using filter expression:

filter(
   all {
      gt {
         zoom()
         get(FeatureProperty.MIN_ZOOM_PROPERTY)
      }
      lt {
         zoom()
          get(FeatureProperty.MAX_ZOOM_PROPERTY)
      }
   }
)
0

There are 0 answers