Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MapLibreGL.VectorSource onPress returns no geometry on Android #538

Closed
jimmyasyraf opened this issue Dec 6, 2024 · 7 comments
Closed

MapLibreGL.VectorSource onPress returns no geometry on Android #538

jimmyasyraf opened this issue Dec 6, 2024 · 7 comments

Comments

@jimmyasyraf
Copy link
Contributor

jimmyasyraf commented Dec 6, 2024

Steps to Trigger Behavior

  1. On Android, add a VectorSource and provide an onPress prop like so
<MapLibreGL.VectorSource onPress={(event) => console.log(event.features)}>
  1. Click on a feature and check the event returned

Expected Behavior

For each feature in event.features there should be geometry

Actual Behavior

For each feature in event.features it returns null for Android. In iOS it returns the geometry with no problem.

Environment

  • Platform: Android (iOS works fine)
  • OS version: Android 14
  • Device type: Pixel 3A
  • Emulator or Simulator: Yes and Physical device as well
  • Development OS: macOS Sonoma 14.5
  • @maplibre/maplibre-react-native Version: 9.0.1
  • react-native Version: 0.73

Additional context

The event for onPress for <MapLibreGL.ShapeSource> for Android is fine too, it returns the geometry

EDIT: I'm only referring to the geometry returned in the onPress event (for Android). Visually, the layer is displayed perfectly fine in the map.

@KiwiKilian
Copy link
Collaborator

I can't reproduce with the current v10 pre-releases, can you try upgrading?

@jimmyasyraf
Copy link
Contributor Author

@KiwiKilian I already did. I previously tried upgrading to 10.0.0-beta.1 and it still happens and now with the just released 10.0.0-beta.2, also still happens - onPress's event.features still returning null.

If it's not confidential, may I know what's the url or tileUrlTemplates (as well as the sourceLayerID and coordinate to zoom to) that you're using so that I can confirm that I can't reproduce it like you did? Then perhaps I can compare your vector tiles with mine, it's possible that my vector tiles are problematic. Nonetheless it still doesn't solve why my vector tile works fine for me on iOS but not on Android.

@KiwiKilian
Copy link
Collaborator

See the here updated example: https://github.com/maplibre/maplibre-react-native/pull/524/files#diff-4084478957dc154afe7df0124654c8135ef0cbfdf2f3916d8b249b0b95c821e5

You can try withing your app like this:

<MapLibreGL.MapView style={{ flex: 1 }}>
    <MapLibreGL.VectorSource
      id="maplibre-tiles"
      url="https://demotiles.maplibre.org/tiles/tiles.json"
      onPress={(event) => {
        console.log(
          `VectorSource onPress: ${event.features}`,
          event.features,
        );
      }}
    >
      <MapLibreGL.FillLayer
        id="countries"
        sourceLayerID="countries"
        style={{
          fillColor: "#ffffff",
          fillAntialias: true,
        }}
      />
    </MapLibreGL.VectorSource>
</MapLibreGL.MapView>

@KiwiKilian
Copy link
Collaborator

Ok, I've tested a bit more and it seems to be flaky in my example. Sometimes there is a geometry, other times it's null.

@jimmyasyraf
Copy link
Contributor Author

@KiwiKilian yes I tested your example and was about to tell you that. Thanks for confirming that you're able to see it too

github-actions bot pushed a commit that referenced this issue Dec 15, 2024
# [10.0.0-beta.9](v10.0.0-beta.8...v10.0.0-beta.9) (2024-12-15)

### Bug Fixes

* `VectorSource` `onPress` returning null geometry on Android ([250ee6f](250ee6f)), closes [#538](#538)
Copy link

🎉 This issue has been resolved in version 10.0.0-beta.9 🎉

The release is available on:

Your semantic-release bot 📦🚀

@tyrauber
Copy link
Collaborator

Thanks @jimmyasyraf for catching, debugging and fixing this! Most appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants