question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MapView's onUserLocationUpdate doesn't seem to fire

See original GitHub issue

Describe the bug MapView’s onUserLocationUpdate doesn’t seem to fire.

To Reproduce

    onUserLocationUpdate = (location) => {
     console.log('location',location);
    }
    render() {
      return (
          <MapboxGL.MapView
            animated
            ref={c => this.map = c}
            styleURL={this.props.theme.styleURL}
            onUserLocationUpdate={this.onUserLocationUpdate}
            onPress={this.onPress}
            logoEnabled={false}
            compassEnabled={false}
            pitchEnabled={false}
            onRegionWillChange={this.onRegionWillChange}
            style={{ flex: 1 }}
            onDidFinishLoadingMap={this.onDidFinishLoadingMap}
            onDidFinishRenderingMap={this.onDidFinishRenderingMap}
            onDidFinishRenderingMapFully={this.onDidFinishRenderingMapFully}
            onDidFinishLoadingStyle={this.onDidFinishLoadingStyle}
            onUserLocationUpdate={this.onUserLocationUpdate}
          >
            <MapboxGL.UserLocation visible={true} renderMode="custom">
              <MapboxGL.CircleLayer id="mapboxUserLocationPluseCircle" style={layerStyles.normal.pulse} />
              <MapboxGL.CircleLayer id="mapboxUserLocationWhiteCircle" style={layerStyles.normal.background} />
              <MapboxGL.CircleLayer id="mapboxUserLocationBlueCicle" aboveLayerID="mapboxUserLocationWhiteCircle" style={layerStyles.normal.foreground} />
            </MapboxGL.UserLocation>

            <MapboxGL.Camera
              followUserLocation={this.state.currentTrackingModeIsFollowing}
              followUserMode="course"
              onUserTrackingModeChange={this.onUserTrackingModeChange}
            />

          </MapboxGL.MapView>
     )
   }

Expected behavior Expected onUserLocationUpdate to fire the callback

Screenshots N/A

Versions (please complete the following information):

  • Platfrom: iOS
  • Device: iPhone 7 Plus
  • OS: iOS 12.3.1.
  • SDK Version: N/A
  • react-native-mapbox-gl Version: 7.0.0-rc3
  • React Native Version 0.56.0

Additional context Just doesn’t seem to fire. I searched the repo’s source code and not sure why it could be not working - seems like onUserLocationUpdate is still a prop of MapView, not Camera. Not quite sure if it’s because of some props i’m passing in. Was working fine 6.1.2

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:26 (18 by maintainers)

github_iconTop GitHub Comments

3reactions
kristfalcommented, Oct 30, 2019

We should create a throttle control for this and onRegionIsChanging similar to ScrollView onScroll. The throttle should happen on native side to prevent unnecessary bridge activity.

Happy to see a PR for this. The RN core ScrollView can be a good source of inspiration for this code.

On Wed, 30 Oct 2019 at 19:39, Richard Lindhout notifications@github.com wrote:

Probably, (maybe by only checking difference in long / lat) but I’m doing some fairly heavy things after a location update, so I don’t want to do that every second. I think somethings like this is the only way since it keeps firing location events even if my device does not do anything.

But I think this should be handled in te library in the native thread, since I think all the debounces are fairly memory heavy. Have no proof for that though 😃

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/react-native-mapbox-gl/maps/issues/246?email_source=notifications&email_token=ABLAPW5MGSAC2IK563FHBHLQRHIELA5CNFSM4IDSMAX2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECVKYII#issuecomment-548056097, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLAPW5W4FLFZPADJSIC52TQRHIELANCNFSM4IDSMAXQ .

2reactions
ferdicuscommented, Nov 14, 2019

Interestingly I’ve noticed, that it not always fires like crazy, sometimes it’s less frequent, sometimes more… I also only monitor it via remote debugger when in the office.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MapView's onUserLocationUpdate doesn't seem to fire #246
Describe the bug MapView's onUserLocationUpdate doesn't seem to fire. To Reproduce onUserLocationUpdate = (location) ...
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 >
Notifications when your shared location is updated - Android
On your home screen or app menu, long press the Google Maps app Maps . Then, tap Info. · Tap Notifications. · Scroll...
Read more >
Reload My Location button when permission is granted
If location access has already been granted, it works as intended. Whoever if the map is already loaded, the My Location button does...
Read more >
How to Tell if Someone Checked Your Location on Snapchat
Snap Map is a Snapchat feature that allows you to view your friends' locations and share yours as well. Sure, that feature sounds...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found