Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement real-time tracking of location in React native? [closed]

I have an ecommerce website and ecommerce app. We sells different products. What I want to do is like Uber or grab app that can track real time location of the taxi going to my location.

So in my app, every time the delivery boy delivers the product to the customer, the delivery boy will see the exact location and direction of his destination. The same as the customer, he/she can see the exact location of the delivery boy. Is it possible to do in React native app and website?

like image 538
Trish Siquian Avatar asked Nov 06 '25 06:11

Trish Siquian


1 Answers

This is actually much easier nowadays, with react-native-maps only, by leveraging the watchPosition observer:

navigator.geolocation.watchPosition(
 position => {
  console.log(position);
  const { latitude, longitude } = position.coords;
  this.setState({ latitude,longitude
 }, 
 error => console.log(error),
 { 
   enableHighAccuracy: true,
   timeout: 20000,
   maximumAge: 1000,
   distanceFilter: 10
 }
);

Here's a great detailed tutorial on how to achieve location tracking in React Native.

like image 146
Dave Elson Avatar answered Nov 08 '25 09:11

Dave Elson