Is it possible to get user location only the first time the component is mounted? #883
-
How do I get user location only the first time the component is mounted? I have a modal and I want to note the location at the time of opening the modal and display it on the map. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Did you try |
Beta Was this translation helpful? Give feedback.
-
Outside the map, use expo-location. 100%! No question. Do not try to use maplibre-react-native to extract user location. The expo-task-manager integration in expo-location is optimized for foreground and background location tracking. @dilaksh06 For long running location tracking in app foreground and background state use expo-location background task with foreground permissions. |
Beta Was this translation helpful? Give feedback.
Did you try
LocationManager.getLastKnownLocation()
within auseEffect
? I'm not sure, if this works without theUserLocation
component beeing rendered, but it's worth a shot.