rnmapbox / maps

A Mapbox react native module for creating custom maps
MIT License
2.11k stars 824 forks source link

[Bug]: isGestureActive is always false on android devices #3495

Open vlasac opened 1 month ago

vlasac commented 1 month ago

Mapbox Implementation

Mapbox

Mapbox Version

default

React Native Version

0.74.1 (expo: 51.0.8)

Platform

Android

@rnmapbox/maps version

10.1.24

Standalone component to reproduce

import React from "react";
import { StyleSheet, View, Dimensions } from "react-native";
import { MapView, setAccessToken } from "@rnmapbox/maps";

const MAPBOX_ACCESS_TOKEN = "pk.ey....";
const MAPBOX_STYLE_URL = "mapbox://styles/...";

export default function App() {
  setAccessToken(MAPBOX_ACCESS_TOKEN);

  return (
    <View style={styles.container}>
      <MapView
        style={styles.mapbox}
        styleURL={MAPBOX_STYLE_URL}
        scaleBarEnabled={false}
        onMapIdle={(mapState) => {
          console.log("MAP IDLE", mapState);

          if (mapState?.gestures.isGestureActive) {
            console.log("USER GESTURE");
          }
        }}
      ></MapView>
    </View>
  );
}

const { height, width } = Dimensions.get("window");

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center",
  },
  mapbox: {
    width,
    height,
    padding: 0,
    margin: 0,
  },
});

Observed behavior and steps to reproduce

Bug description:

In the code example shared above you can see that there are two console logs in the onMapIdle function, the first one prints the whole map state and the second one is logged if the user gesture is active.

The code works in a sense that the event is invoked on every map idle, but the issue I noticed is that on Android devices the second log never appears in the console because isGestureActive is always false, regardless if the map has idled programatically or by user gesture.

On iOS this variable accurately reflects the state of the map interaction and both logs can be observed in the console after the user stops dragging the map.

Expected behavior

I would expect the same behaviour on Android as it is currently on iOS - the map state passed to the onMapIdle is always reflecting the current state of gesture interactions.

Notes / preliminary analysis

No response

Additional links and references

No response

meribes124 commented 1 month ago

I am having this issue as well

alainib commented 1 month ago

i have this issue too. i swipe the map fast , i get like lots of calls to onCameraChanged (normal) , many of them have "isGestureActive": false and others "isGestureActive": true

el0marca commented 1 week ago

Does anyone have a solution?