react-native-gps

0.1.1 • Public • Published

react-native-gps

Native GPS location support for React Native for Android and IOS. Was inspired in project of timfpark and syarul

Installation

Pending: not released yet

Location Usage

var React = require('react-native');
var { DeviceEventEmitter } = React;
 
var { RNLocation: Location } = require('NativeModules');
 
Location.startUpdatingLocation();
 
var subscription = DeviceEventEmitter.addListener(
    'locationUpdated',
    (location) => {
        /* Example location returned
        {
          speed: -1,
          longitude: -0.1337,
          latitude: 51.50998,
          accuracy: 5,
          heading: -1,
          altitude: 0,
          altitudeAccuracy: -1
          timestamp: 1446007304457.029
        }
        */
    }
);

Methods

To access the methods, you need import the react-native-location module. This is done through var Beacons = require('react-native-location').

Location.requestWhenInUseAuthorization

Location.requestWhenInUseAuthorization();

This method should be called before anything else. It requests location updates while the application is open. If the application is in the background, you will not get location updates.

Location.startUpdatingLocation

Location.startUpdatingLocation();
var subscription = DeviceEventEmitter.addListener(
    'locationUpdated',
    (location) => {
        // do something with the location
    }
);

License

MIT, for more information see LICENSE

Package Sidebar

Install

npm i react-native-gps

Weekly Downloads

0

Version

0.1.1

License

MIT

Last publish

Collaborators

  • agrass