mapbox-maps-android icon indicating copy to clipboard operation
mapbox-maps-android copied to clipboard

queryRenderedFeatures randomly returning empty list

Open alfietapping opened this issue 3 years ago • 2 comments

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

alfietapping avatar Apr 13 '22 14:04 alfietapping

@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?

ZiZasaurus avatar Jul 30 '22 02:07 ZiZasaurus

@hirschan are you still experiencing this behavior in the newer version of our SDK?

ZiZasaurus avatar Oct 24 '22 22:10 ZiZasaurus