New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-geolocation-service

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-geolocation-service

React native geolocation service for iOS and android

5.3.1
latest
Source
npm
Version published
Weekly downloads
124K
0.46%
Maintainers
1
Weekly downloads
 
Created

What is react-native-geolocation-service?

The react-native-geolocation-service package provides a simple and consistent API for accessing the device's geolocation capabilities. It is designed to be a drop-in replacement for the deprecated navigator.geolocation API in React Native, offering more reliable and accurate location data.

What are react-native-geolocation-service's main functionalities?

Get Current Position

This feature allows you to get the current position of the device. The code sample demonstrates how to use the getCurrentPosition method to retrieve the device's current location with high accuracy.

```javascript
import Geolocation from 'react-native-geolocation-service';

Geolocation.getCurrentPosition(
  (position) => {
    console.log(position);
  },
  (error) => {
    console.error(error);
  },
  { enableHighAccuracy: true, timeout: 15000, maximumAge: 10000 }
);
```

Watch Position

This feature allows you to continuously watch the device's position. The code sample demonstrates how to use the watchPosition method to start watching the device's location and how to stop watching using the clearWatch method.

```javascript
import Geolocation from 'react-native-geolocation-service';

const watchId = Geolocation.watchPosition(
  (position) => {
    console.log(position);
  },
  (error) => {
    console.error(error);
  },
  { enableHighAccuracy: true, distanceFilter: 0, interval: 5000, fastestInterval: 2000 }
);

// To stop watching position
Geolocation.clearWatch(watchId);
```

Stop Observing Position

This feature allows you to stop all ongoing location observations. The code sample demonstrates how to use the stopObserving method to stop any active geolocation tracking.

```javascript
import Geolocation from 'react-native-geolocation-service';

Geolocation.stopObserving();
```

Other packages similar to react-native-geolocation-service

Keywords

react-native

FAQs

Package last updated on 23 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts