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

Geolocation watchPosition update rate #21061

Closed
3 tasks done
davidwwu opened this issue Sep 12, 2018 · 5 comments
Closed
3 tasks done

Geolocation watchPosition update rate #21061

davidwwu opened this issue Sep 12, 2018 · 5 comments
Labels
API: Geolocation Bug Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@davidwwu
Copy link

davidwwu commented Sep 12, 2018

Environment

React Native Environment Info:
  System:
    OS: macOS High Sierra 10.13.6
    CPU: x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
    Memory: 4.02 GB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.1.0 - /usr/local/bin/node
    npm: 6.0.1 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 11.4, macOS 10.13, tvOS 11.4, watchOS 4.3
  IDEs:
    Xcode: 9.4.1/9F2000 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.5.0 => 16.5.0
    react-native: 0.57.0 => 0.57.0
  npmGlobalPackages:
    create-react-native-app: 1.0.0
    react-native-cli: 2.0.1

Description

I'm making a generic google map (for now) with live user location:

navigator.geolocation.watchPosition(
  ({coords}) => {
    const {latitude, longitude} = coords

    this.setState({
      position: {
        latitude,
        longitude,
      },
      region: {
        latitude,
        longitude,
        latitudeDelta: 0.0922,
        longitudeDelta: 0.0421,
      }
    })
  },
  (error) => alert(JSON.stringify(error)),
  {enableHighAccuracy: true, timeout: 20000, maximumAge: 0, distanceFilter: 0}
)

However, the current position's update rate is very slow--at about 5-8 second/update.

I'm not entirely sure if this is a bug or an expected behavior, but I've built a similar app using ionic + google map javascript api and the update rate is real-time, so I don't think this 5-8 second/update rate is normal.

Reproducible Demo

Please check out my issue branch to reproduce the app/bug.

@react-native-bot
Copy link
Collaborator

It looks like you are using an older version of React Native. Please update to the latest release, v0.57 and verify if the issue still exists.

The ":rewind:Old Version" label will be removed automatically once you edit your original post with the results of running react-native info on a project using the latest release.

@davidwwu
Copy link
Author

davidwwu commented Sep 21, 2018

As I’m digging around, looks like the enableHighAccuracy option is somehow not working properly because I can get accurate returns from watchPosition including heading, speed, and accuracy if I open other map apps such as Google Maps and iOS’ Maps and jump back to my app. But it only operates for a few seconds before it starts returning the “less accurate” results (most noticible accuracy jumps from 10 to 65 and of course the much less often location return rate).

@MariamMobeen
Copy link

How did you solve it?

@stale
Copy link

stale bot commented Aug 2, 2019

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Aug 2, 2019
@stale
Copy link

stale bot commented Aug 9, 2019

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Aug 9, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Aug 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
API: Geolocation Bug Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

5 participants