[Bug] Scroll zoom stops short of maxZoom in controlled mode with MapLibre

Open
#2,626 0 comments 0 reactions 0 assignees View on GitHub

@sviat-barbutsa is already working on this.

Since Oct 29, 2026.

  • #2627 by @sviat-barbutsa — open

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
Domain
frontend, web-dev

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

bug
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 }}
    />
  );
}
  1. Render Controlled.
  2. Scroll in continuously (two-finger trackpad scroll, or a mouse wheel) until the map stops zooming.
  3. Read mapRef.current.getMap().getZoom(): it is below 18.
  4. 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-maplibre 8.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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from visgl/react-map-gl

All issues in visgl/react-map-gl

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.