mapbox-maps-android icon indicating copy to clipboard operation
mapbox-maps-android copied to clipboard

[API Design] getters and setters for minZoom/maxZoom behave inconsistently

Open florianPOLARSTEPS opened this issue 3 years ago • 1 comments

Environment

  • Android OS version: Any
  • Devices affected: Any
  • Maps SDK Version: 10.8.1

Observed behavior and steps to reproduce

Given in my style I have any layer with no min/ max zoom properties set, like the following:

{
      "id" : "vector_land",
      "type" : "background",
      "layout" : {},
      "paint" : {...},
      "metadata" : {
        "mapbox:featureComponent" : "land-and-water",
        "mapbox:group" : "Land, water, & sky, land"
      }
    }

By accessing the zoom properties via layer.minZoom or layer.maxZoom the values returned are Double.POSITIVE_INFINITY and Double.NEGATIVE_INFINITY.

The corresponding API to set the zoom properties though throws an exception when setting those values

val minZoomFromStyle = layer.minZoom
layer.minZoom(minZoomFromStyle)
// throws java.lang.IllegalArgumentException: Incorrect property value for minzoom: Value can not be Double.NaN, Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY

The documentation for minZoom and maxZoom is also outdated Screenshot 2022-10-18 at 10 17 52

Expected behavior

A well designed API or a changelog that contains breaking changes and accompanying documentation.

florianPOLARSTEPS avatar Oct 18 '22 08:10 florianPOLARSTEPS

@florianPOLARSTEPS I've created an internal task to check if it is still the case in latest versions of our SDK. Thanks for bringing it up.

kiryldz avatar Oct 26 '24 17:10 kiryldz

I've tested with latest Maps SDK release v11.11.0-rc.1 and the result I get from the layer.minZoom is 0.0 and layer.maxZoom is 25.5. Closing as not relevant any more.

pengdev avatar Mar 19 '25 16:03 pengdev