Mapbox-gl-js queryRenderedFeatures not working.
andersonn-roberto opened this issue · 5 comments
Hi,
First, thank you for this plugin.
I'm trying to get a layer features by clicking on a polygon on map.
I'm using MapTiler vector tiles that brings the layer information with the map images, but I can't get the features related to some polygon.
I saw a closed issue that uses featuresAt function, but this function doesn't exists anymore.
Do you have some suggestions to get this working?
Thanks!
Hi,
After spending some time on MapBox-GL-Js directly I managed to get this plugin to work as expected.
If anyone have problem and want an example, just let me know.
Thanks!
I am also facing issue with raster. do you have idea?
You can see a fragment of code that I'm using on an app:
map.on('click', function (e)
{
// set bbox as 5px reactangle area around clicked point
var bbox = [
[e.containerPoint.x - 1, e.containerPoint.y - 1],
[e.containerPoint.x + 1, e.containerPoint.y + 1]
];
var features = gl._glMap.queryRenderedFeatures(bbox, {
layers: ['plis']
});
...
I'm using Leaflet with Mapbox-GL-Leaflet.
Could it be possible to query a feature by a clicked point, instead of a bbox?
Could it be possible to query a feature by a clicked point, instead of a bbox?
I don't think so, but you can check the queryRenderedFeatures function on MapBox GL documentation.