0

What I'm looking for?

I want to get notified when the user swipes/pans the pan to check other locations. The only only event I could find is onPress but it is only fired when the user actually presses on the map, but if the user swipes the map to change view it doesn't get fired.

What I need it for

I want to know if the user swiped the map and the user's location is not the center of the map anymore. If yes, then show a button to center map around the user's location. Like I said, how do I know if the user swiped.

What am I using Mapbox SDK for react-native (currently only testing on ios but I need it to work on ios and android in the future).

What I have tried so far

onRegionWillChange = { ( ) => this.myfunction() }

myfunction here only gets notified when the region loaded changes, not when the user is not centered anymore.

this._map.getCenter()

I user this to know if thee center of the map is the user's location. But I am looking again for the event that gets fired when the user swipes & then I would call this function to verify the swipe.

Any Help is very much apprechiated

1 Answers1

1

I've no experience using the SDK for react-native, but using the JS version you can use on drag events. It might lead you to a way to do it using the react-native SDK.

There are three types.

  • drag
  • dragend
  • dragstart

This shows an example that listen for the drag event and writes out the current center of the map to console.

this._map.on("drag", (x) => {
  console.log(this._map.getCenter());
});
Notation
  • 71
  • 4