npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-get-location

v5.0.0

Published

⚛ Simple to use React Native library to get device location for Android and iOS.

Downloads

49,946

Readme

React-Native Get Location

License MIT npm version npm downloads

⚛ Simple to use React Native library to get native device location for Android and iOS.

Requirements

  • React Native >= 0.60.0
  • iOS >= 9.0

Install

Install dependency package

yarn add react-native-get-location

Or

npm i -S react-native-get-location

Go to the folder your-project/ios and run pod install, and you're done.

Android post install

For Android you need to define the location permissions on AndroidManifest.xml.

<!-- Define ACCESS_FINE_LOCATION if you will use enableHighAccuracy=true  -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<!-- Define ACCESS_COARSE_LOCATION if you will use enableHighAccuracy=false  -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

iOS post install

You need to define the permission NSLocationWhenInUseUsageDescription on Info.plist.

<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs to get your location...</string>

Usage

There is only one function that you need to use to get the user's current location.

import GetLocation from 'react-native-get-location'

GetLocation.getCurrentPosition({
    enableHighAccuracy: true,
    timeout: 60000,
})
.then(location => {
    console.log(location);
})
.catch(error => {
    const { code, message } = error;
    console.warn(code, message);
})

For more details, see the Sample Project.

API

function GetLocation.getCurrentPosition(LocationConfig)

Parameters:

  • LocationConfig: Configuration object to determine how to get the user current location.

Return:

  • Promise<Location>: Promise thats resolve to a Location object.

Object LocationConfig

Properties:

  • enableHighAccuracy: Set true to use 'fine location' (GPS) our false to use 'course location' (Wifi, Bluetooth, 3G). Default: false
  • timeout: The max time (in milliseconds) that you want to wait to receive a location. Default: 60000 (60 seconds)
  • rationale?: (Android only) See the React Native docs.

Object Location

Properties:

  • latitude: The latitude, in degrees.
  • longitude: The longitude, in degrees.
  • altitude: The altitude if available, in meters above the WGS 84 reference ellipsoid.
  • accuracy: The estimated horizontal accuracy of this location, radial, in meters.
  • speed: The speed if it is available, in meters/second over ground.
  • time: The UTC time of this fix, in milliseconds since January 1, 1970.
  • bearing: (Android only) The bearing, in degrees.
  • provider: (Android only) The name of the provider that generated this fix.
  • verticalAccuracy: (iOS only) The vertical accuracy of the location. Negative if the altitude is invalid.
  • course: (iOS only) The course of the location in degrees true North. Negative if course is invalid. (0.0 - 359.9 degrees, 0 being true North)

Error codes

|Code|Message| |-|-| |CANCELLED|Location cancelled by user or by another request| |UNAVAILABLE|Location service is disabled or unavailable| |TIMEOUT|Location request timed out| |UNAUTHORIZED|Authorization denied|

Contribute

New features, bug fixes and improvements are welcome! For questions and suggestions use the issues.

Donate

Star History

Star History Chart

License

The MIT License (MIT)

Copyright (c) 2019 Douglas Nassif Roma Junior

See the full license file.