Hi! I have a simple question about how to perform certain events (click and hover) on the <Layer /> component. I want to do something similar to this: https://www.mapbox.com/mapbox-gl-js/example/query-similar-features/ Basically interact with the vector tile layer, altering its paint properties, get underlying data and so on. What would be best way to perform this? I see that the <Layer /> component does not have specific events like feature and geojsonlayer.
Thanks for all the hard work on this library!
You can use the events on the Mapbox object to get features under the mouse pointer, doesn't matter if it's an included layer or data layer. You can filter the results if you want to do specific actions afterwards. You can look at the other events in the documentation.
`
....
_onMapClick = (map,evt) => {
console.log('Map clicked!',evt.lngLat.lat,evt.lngLat.lng);
const features = map.queryRenderedFeatures(evt.point);
console.log(features);
}`
Tried using this but features is returning empty array in every case.
@mklopets - im starting to work on a PR to add this functionality
Added in #675
Most helpful comment
You can use the events on the Mapbox object to get features under the mouse pointer, doesn't matter if it's an included layer or data layer. You can filter the results if you want to do specific actions afterwards. You can look at the other events in the documentation.
`
onClick={this._onMapClick}
....
_onMapClick = (map,evt) => {
console.log('Map clicked!',evt.lngLat.lat,evt.lngLat.lng);
const features = map.queryRenderedFeatures(evt.point);
console.log(features);
}`