How to implement real-time tracking of location in React native app and in website?

10,843

Solution 1

Yes, it is possible. You'll have to take a look into react-native-maps and also react-native-bridge for the gps tracking. You should check out jscoach, there you can search for packages that will fulfill your needs.

Solution 2

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.

Share:
10,843

Related videos on Youtube

Trish Siquian
Author by

Trish Siquian

Updated on June 04, 2022

Comments

  • Trish Siquian
    Trish Siquian almost 2 years

    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?

    • Jose Vf
      Jose Vf over 5 years
      It is possible, even Uber Eats was developed with React Native.
    • Trish Siquian
      Trish Siquian over 5 years
      what specific software or tools should I use?