Skip to content

[Bug] Changing minZoom and maxZoom at the same time can throw an error in Maplibre #2572

@Auspicus

Description

@Auspicus

Description

A recent change (maplibre/maplibre-gl-js#6766) introduced into the way that maplibre-gl handles setMinZoom and setMaxZoom calls to prevent stale values means that these changes are applied immediately.

As such, a change in props from { minZoom: 1, maxZoom: 3 } to { minZoom: 5, maxZoom: 10 } can throw an error in Maplibre depending on the order in which these are updated. If setMinZoom is called first the new minZoom: 5 is greater than the current maxZoom: 3 and an error is thrown (https://github.com/maplibre/maplibre-gl-js/blob/main/src/ui/map.ts#L1154). Maybe there's an order to call these in that always works? Or we request an upstream function eg. setZoomConstraint({ min: x, max: y }) that changes both in one go?

Expected Behavior

No response

Steps to Reproduce

  • Create a map with { ..., minZoom: 1, maxZoom: 3 } props
  • Change props to { minZoom: 5, maxZoom: 10 }
  • Note error thrown

Environment

  • Framework version: react-map-gl@8.1.0
  • Map library: maplibre-gl@5.15.0
  • Browser: N/A
  • OS: N/A

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions