feat(user-location): locationManager is not stopped on unmount
See original GitHub issueDescribe the bug
I’ve noticed that within the UserLocation
components method #setLocationManager
locationManager
is never really stopped.
On componentWillUnmount
we’re passing { running: false }
, however this will simply prevent a restart of locationManager
Not sure, however this might cause the locationManager
running when the map/ userlocation is unmounted.
To Reproduce Have a MapView mount UserLocation component and unmount it again. Notice, that the GPS indicator is still visible in the devices statusbar.
Expected behavior GPS tracking/ indicator is gone once the UserLocation component is unmounted.
Screenshots na
Versions (please complete the following information):
- Platform:
OS X
- Device:
LG Q7
- Emulator/ Simulator:
no
- OS:
Android
- SDK Version:
Android 9
- React Native Version:
7.2.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
locationManager is not stopped on unmount · Issue #663 ...
Describe the bug I've noticed that within the UserLocation components method #setLocationManager locationManager is never really stopped.
Read more >why self.locationManager stopUpdatingLocation doesn't stop ...
This is because stopUpdatingLocation just tells the LocationManager that your locationManager is no longer interested in location updates.
Read more >Core Location | Apple Developer Forums
Location Stops When the App is Backgrounded after some time. I am working on an app that requires location to work in the...
Read more >Turn working location on or off for users - Google Help
If you turn working location off, it may take up to 36 hours to remove the working location feature and delete user working...
Read more >How to Get User Location on a Map - Swift - YouTube
Head to https://squarespace.com/seanallen to save 10% off your first purchase of a website or domain using code SEANALLEN.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ll try give this a chance in the coming weeks - seems like an oversight which might cause people headaches with active GPS, when they’re no longer on the map/ have no userlocation shown.
Thanks for the feedback!
Looking at native codes on ios and android there doesn’t seems to be a difference in pause and dispose.
.pause
is buggy as it should be callingremoveListener
if it setsisListening
to falsehttps://github.com/react-native-mapbox-gl/maps/blob/9e76f32063762d43a8b8c43b1b7e8aa784f65da6/javascript/modules/location/locationManager.js#L66-L71