react-mapbox-gl
react-mapbox-gl copied to clipboard
onClick not working on Feature
Render:
<Layer type="heatmap" paint={layerPaint} > {data.map((point, index) => ( <Feature key={index} coordinates={point.latlng} properties={point} onclick={() => this.handleClick(point)} /> ))} </Layer>
Function:
handleClick = (e) => { console.log(e) }
use onClick instead of onclick in Feature
I dont have idea how it changed onClick to onclick, but this two options not work

what is happening then you change in the onClick this.handleClick(item) to console.log('blablabla')? Appears the log in the console?
No appear in console
any solution :|
I believe you need to move the onClick
prop to the map element.
You can then handle the click, grab the id of the element that was clicked and update your state above to reflect the change you'd like to make.
Let me know how that goes.