Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maxZoom: 0 is ignored #13366

Open
FiodarHmyza opened this issue Dec 20, 2024 · 0 comments
Open

maxZoom: 0 is ignored #13366

FiodarHmyza opened this issue Dec 20, 2024 · 0 comments

Comments

@FiodarHmyza
Copy link

FiodarHmyza commented Dec 20, 2024

mapbox-gl-js version: 3.9.0

browser: Chrome 131.0.6778.205

Steps to Trigger Behavior

  1. Open example https://docs.mapbox.com/mapbox-gl-js/guides
  2. In the suggested JS editor, set maxZoom to 0:
   const map = new mapboxgl.Map({
       container: 'map',
       style: 'mapbox://styles/mapbox/streets-v9',
       projection: 'globe', // Display the map as a globe, since satellite-v9 defaults to Mercator
       zoom: 1,
       maxZoom: 0,
       center: [30, 15]
   });

Link to Demonstration

https://jsfiddle.net/7em46qau/2/

Expected Behavior

Maximum zoom level 0 should be accepted as any other possible levels: user should not zoom in beyond this level.

Actual Behavior

maxZoom is ignored like there is no value at all.

Possible solution

Most likely, the existence of a property is checked with simple JS if (property) code. It will produce false for 0. Additional check on 0 value should work: if (property || property === 0).

Temporal workaround

Set maxZoom to 0.0001. It should pass existence check and then it will be rounded to 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant