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

queryRenderedFeatures results in empty list when using layerIds in RenderedQueryOptions.

Open manulgdc opened this issue 1 year ago • 2 comments

Here is my code, which is inside my _onMapTapped() function :

List<QueriedRenderedFeature?> queriedRenderedFeatures = await mapboxMap!.queryRenderedFeatures(
      RenderedQueryGeometry(value: jsonEncode(screenCoordinate.encode()), type: Type.SCREEN_COORDINATE),
      RenderedQueryOptions(filter: null),
    );
 if (queriedRenderedFeatures.isNotEmpty) {
      queriedRenderedFeatures.forEach((element) {
        print(element?.layers.toString());
        print(element?.queriedFeature.feature["id"]);
      });
    } else {
      print("no result");
    }

And it produces the expected output ;

Screenshot 2024-03-27 at 13 48 09

But as soon as I change RenderedQueryOptions(filter: null) to RenderedQueryOptions(layerIds: ["landuse"], filter: null),

and click on the same spot I get empty results :

Screenshot 2024-03-27 at 13 49 41

manulgdc avatar Mar 27 '24 12:03 manulgdc

Probably due to #190

manulgdc avatar Mar 27 '24 14:03 manulgdc

@manulgdc Thank you for making the report! Is this behavior consistent across platforms(iOS/Android)? Do you use one of the default styles? I couldn't reproduce this behavior - for me the results are still there when I specify a layerId, I tested it with the MapStyle.Light.

evil159 avatar Apr 08 '24 11:04 evil159