react-map-gl
react-map-gl copied to clipboard
[Bug] Clustering example - onClick returning undefined
Description
The clustering example onClick function is returning undefined when clicking outside of clusters and on empty map space.
Expected Behavior
OnClick function to not return undefined.
Steps to Reproduce
- Go to react-map-gl clustering example: http://visgl.github.io/react-map-gl/examples/clusters
- Open up console
- Click on a specific point or any empty map space
- Notice error in console
Environment
- Framework version: Current/latest from assuming examples are running on latest build
- Map library: Current/latest from assuming examples are running on latest build
- Browser: Chrome 108.0
- OS: 13.1
Logs
Uncaught TypeError: Cannot read properties of undefined (reading 'properties') at onClick (component---examples-clusters-src-app-tsx-ae435c98aa31b91df409.js:1:1591) at Map._onPointerEvent (834b8338ea35f2c3d17eb82aef29032efb222d04-d473b88aba9c068a3050.js:1:20732) at Map.fire (27-9fafbe3fd9a64912bea8.js:1:18842) at t._fireEvent (834b8338ea35f2c3d17eb82aef29032efb222d04-d473b88aba9c068a3050.js:1:25834) at Qr.click (27-9fafbe3fd9a64912bea8.js:1:813462) at Rn.handleEvent (27-9fafbe3fd9a64912bea8.js:1:838674)
Is there any news about this? One year passed and it is still an issue I am facing.
The issue is that the event.features
should be checked before indexing here.
FWIW changing that alone would prevent the error, but would leave the example short of reproducing the example here, which is the stated intention. To do that, we'd need to add the other layers in interactiveLayerIds
, and actually create the popup.