[Bug] Scroll zoom stops short of maxZoom in controlled mode with MapLibre
Assessment
- Difficulty
- 3/5
- Estimated time
- Half a day
- Newbie friendliness
- 74/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- react, typescript
Research direction
Start at the controlled viewState and onMove handling in the react-map-gl Map component, then trace how scroll zoom updates are passed back to MapLibre. Compare the controlled path with the uncontrolled behavior using the provided reproduction and check the final zoom against maxZoom. Done means both trackpad and wheel scrolling reach exactly 18 in controlled mode.
Written by the indexing model from the issue text.
Description
Description
With a controlled Map from react-map-gl/maplibre, using the {...viewState} / onMove={evt => setViewState(evt.viewState)} pattern from the state management docs, scrolling in never reaches maxZoom:
A continuous trackpad scroll stops at about maxZoom - 0.015 (17.984640764116154 with maxZoom: 18).
Mouse wheel scrolling stops at 17.999999999999996.
Because the zoom never reaches maxZoom, layers with minzoom equal to maxZoom never show, and layers with maxzoom equal to maxZoom never hide. For example, a heatmap that should switch to markers at the maximum zoom never switches.
The same map in uncontrolled mode (initialViewState), and plain MapLibre without react-map-gl, both reach exactly 18.
Expected Behavior
Scroll zoom reaches maxZoom exactly, the same as in uncontrolled mode and in plain MapLibre.
Steps to Reproduce
import { useState } from 'react';
import Map from 'react-map-gl/maplibre';
import 'maplibre-gl/dist/maplibre-gl.css';
const mapStyle = { version: 8, sources: {}, layers: [] };
export function Controlled() {
const [viewState, setViewState] = useState({
longitude: -3.16,
latitude: 51.5,
zoom: 15,
});
return (
<Map
{...viewState}
onMove={(evt) => setViewState(evt.viewState)}
maxZoom={18}
mapStyle={mapStyle}
style={{ width: 600, height: 400 }}
/>
);
}
export function Uncontrolled() {
return (
<Map
initialViewState={{ longitude: -3.16, latitude: 51.5, zoom: 15 }}
maxZoom={18}
mapStyle={mapStyle}
style={{ width: 600, height: 400 }}
/>
);
}
- Render
Controlled. - Scroll in continuously (two-finger trackpad scroll, or a mouse wheel) until the map stops zooming.
- Read
mapRef.current.getMap().getZoom(): it is below 18. - Repeat with
Uncontrolled: the zoom reaches exactly 18.
Results from scripted WheelEvents dispatched on the map canvas. "Trackpad" means 400 events of deltaY about −2.5 to −4, 16 ms apart, with no pause. "Wheel" means 60 events of deltaY: -100, 50 ms apart.
| Setup | Trackpad | Wheel |
|---|---|---|
| react-map-gl, controlled | 17.984640764116154 | 17.999999999999996 |
| react-map-gl, uncontrolled | 18 | 18 |
| maplibre-gl only, no react-map-gl | 18 | not run |
I see the same in an app with real ⌘ + two-finger trackpad scrolling. Lifting the fingers and scrolling again then reaches 18.
Environment
- Framework version: react-map-gl 8.1.3 (
@vis.gl/react-maplibre8.1.3), React 19.3.0 - Map library: maplibre-gl 6.15.0
- Browser: Chrome 156
- OS: macOS 27.2
Logs
No response
- Dominant language
- TypeScript
- Stars
- 8.5k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from visgl/react-map-gl
-
DEFAULT_SETTINGS.maxBounds in @vis.gl/react-maplibre has 360° longitude span, triggers maplibre-gl-js#6148 crash via _updateSettings fallbackMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
visgl/react-map-gl#2591 · 2 comments ·
-
[Bug] Mapbox geocoder example crashes: "i is not a function"Possibly taken @yuiseki claimed this 20 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
visgl/react-map-gl#2628 ·
-
[Bug] reuseMaps: Mapbox.reuse() infinite-loops (tab freeze) when the recycled map's container is the mount containerPossibly taken @mikeyfarina claimed this 82 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 68/100
visgl/react-map-gl#2613 ·
-
feature
Difficulty 5/5 Over a week Newbie friendliness 42/100
visgl/react-map-gl#2603 · 1 reaction ·
-
[Bug] Prop `style` does not unset properties that become `undefined`Possibly taken @MohammadYusif claimed this 140 days ago. Openbug
Difficulty 3/5 1-2 days Newbie friendliness 66/100
visgl/react-map-gl#2595 · 3 comments ·
All issues in visgl/react-map-gl
Similar issues
-
accessibility area:ci ci-test level:low priority:high type:test
Difficulty 2/5 1-3 hours Newbie friendliness 71/100
skytuhua-org/Gen-V1#3132 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
drmrd/vernacular#1238 ·
Maintainers usually reply within 1 day
-
question
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
enhancement migration-prioritized
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Hudson-Pufferfish/local-party-console#136 ·
Maintainers usually reply within 1 day
-
priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day