Skip to content

[Bug]: : Location icon displaying continuously even coming out of the mapview #3873 #3874

@Swaroopa-Agribridge

Description

@Swaroopa-Agribridge

Mapbox Implementation

Mapbox

Mapbox Version

"@rnmapbox/maps": "^10.1.30",

React Native Version

"react-native": "0.74.2",

Platform

Android

@rnmapbox/maps version

10.1.30

Standalone component to reproduce

  <MapboxGL.MapView style={{ flex: 1 }}>
        <MapboxGL.Camera
          zoomLevel={20}
          centerCoordinate={[78.486671,17.385044]} // Example coords
          followUserLocation={followLocation}
        />

        {showUserLocation && (
          <MapboxGL.UserLocation
            visible={true}
            androidRenderMode="normal"
          />
        )}
      </MapboxGL.MapView>


  // Stop location updates on unmount
  useEffect(() => {
    return () => {
      stopLocation();
    };
  }, []);

  // Handle Android back press
  useEffect(() => {
    const backHandler = BackHandler.addEventListener('hardwareBackPress', () => {
      stopLocation();
      navigation.goBack();
      return true;
    });

    return () => backHandler.remove();
  }, []);

const stopLocation = () => {
  if (!hasStoppedRef.current) {
    hasStoppedRef.current = true;
    setShowUserLocation(false);
    setFollowLocation(false);
    MapboxGL.locationManager.stop();
  }
};
useEffect(() => {
  if (isFocused && !hasStartedRef.current) {
    MapboxGL.locationManager.start();
    hasStartedRef.current = true;
    setShowUserLocation(true);
    setFollowLocation(true);
  }
}, [isFocused]);

Observed behavior and steps to reproduce

I am stopping the location but it is not stopping and the location icon is still visible in the status bar continuously fetching

Expected behavior

When click on any back button I am going back to previous screens I want to stop the live location and the location icon should be gone

Notes / preliminary analysis

No response

Additional links and references

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions