mapbox-gl-js
mapbox-gl-js copied to clipboard
addInteraction with type ‘wheel’ causes Uncaught TypeError in createFromScreenPoints
mapbox-gl-js version: 3.7.0
browser: chrome latest
Steps to Trigger Behavior
- Use
addInteractionwith the type set to'wheel'. - Trigger a wheel event (e.g., by scrolling with the mouse wheel over the map).
- Observe that the error is thrown during the wheel event handling.
Link to Demonstration
mapbox-gl.js?v=c1486394:17622 Uncaught TypeError: Cannot read properties of undefined (reading ‘0’)
at Xe.createFromScreenPoints (mapbox-gl.js?v=c1486394:17622:59)
at To._queryRenderedFeatures (mapbox-gl.js?v=c1486394:22766:72)
at To.queryRenderedTargets (mapbox-gl.js?v=c1486394:22762:29)
at ol.queryTargets (mapbox-gl.js?v=c1486394:28488:35)
at ol.handleType (mapbox-gl.js?v=c1486394:28504:29)
at Map.fire (mapbox-gl.js?v=c1486394:1852:39)
at un._firePreventable (mapbox-gl.js?v=c1486394:27058:27)
at un.wheel (mapbox-gl.js?v=c1486394:27021:25)
at $n.handleEvent (mapbox-gl.js?v=c1486394:27901:108)
Expected Behavior
zoom in or out of map
Actual Behavior
cannot zoom in or out cause of above error
my code in editor:
map.addInteraction(INTERACTION_ID.MAP_ZOOM, {
type: "wheel",
target: { layerId: LAYER_ID.STATIONS_LAYER_ID },
handler: (e) => {
e.preventDefault();
console.log(e);
requestIdleCallback(() => {
map.getCanvas().style.cursor = "crosshair";
});
},
});