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

Aperta
#2,626 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@sviat-barbutsa ci sta già lavorando.

Dal 29/10/2026.

  • #2627 di @sviat-barbutsa — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
74/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
react, typescript
Ambito
frontend, web-dev

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
TypeScript
Stelle
8.5k
Fork
1.3k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di visgl/react-map-gl

Tutte le issue di visgl/react-map-gl

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.