react-map-gl icon indicating copy to clipboard operation
react-map-gl copied to clipboard

[Bug] Clustering example - onClick returning undefined

Open JamesLeBoeuf opened this issue 2 years ago • 2 comments

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

  1. Go to react-map-gl clustering example: http://visgl.github.io/react-map-gl/examples/clusters
  2. Open up console
  3. Click on a specific point or any empty map space
  4. 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)

JamesLeBoeuf avatar Jan 06 '23 04:01 JamesLeBoeuf

Is there any news about this? One year passed and it is still an issue I am facing.

kamami avatar Jan 03 '24 16:01 kamami

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.

lswainemoore avatar Feb 14 '24 21:02 lswainemoore