mapbox-maps-android
mapbox-maps-android copied to clipboard
queryRenderedFeatures randomly returning empty list
Environment
- Android OS version: 12
- Devices affected:
- Maps SDK Version: 10.2.0
Observed behavior and steps to reproduce
I'm loading numerous vector tiles and using queryRenderedFeatures to try and get the coordinate info of the tile im selecting, however this only seems to work randomly, usually not working at all and returning an empty list.
mapView.getMapboxMap().loadStyleUri(mapStyle) {
val source = vectorSource(sourceId) {
minzoom(14)
maxzoom(16)
tiles(listOf("https://xxx/api/maps/mvt/{z},{x},{y}.pbf?apikey=xxx"))
}
val lineLayer = lineLayer(lineLayerId, sourceId) {
minZoom(14.0)
maxZoom(22.0)
sourceLayer(sourceLayerId)
lineColor(
ContextCompat.getColor(
mapView.context,
R.color.layer_line
)
)
lineWidth(2.0)
}
it.addSource(source)
it.addLayer(lineLayer)
}
mapView.getMapboxMap().addOnMapClickListener { point ->
val queryOptions = RenderedQueryOptions(listOf(lineLayerId), null)
mapView.getMapboxMap().queryRenderedFeatures(
geometry = RenderedQueryGeometry(
mapView.getMapboxMap().pixelForCoordinate(point)
),
options = queryOptions,
callback = {
Log.d("FEATURE", it.value.toString())
}
)
true
}
Expected behavior
Notes / preliminary analysis
Additional links and references
@hirschan, thank you for providing your experience with this behavior. Can you provide the version of the SDK where you are currently experiencing this behavior?
@hirschan are you still experiencing this behavior in the newer version of our SDK?