0.0.9 • Published 4 years ago

react-native-community-geolocation v0.0.9

Weekly downloads
10
License
MIT
Repository
github
Last release
4 years ago

react-native-community-geolocation

npm Supports Android MIT License

npm total downloads npm monthly downloads npm weekly downloads

Device Information for React Native. Here's an image the example:

Move along.

Getting started

Until now only Android

using yarn

$ yarn add react-native-community-geolocation --save

using npm

$ npm install react-native-community-geolocation --save

Mostly automatic installation react version < 0.6

$ react-native link react-native-community-geolocation

Usage

import React, { useState, useEffect } from "react";
import { StyleSheet, Text, View, Button } from "react-native";
import Geolocation from "react-native-community-geolocation";

export default function App() {
  const [status, setStatus] = useState("starting");
  const [message, setMessage] = useState("message");

  async function getGeolocation() {
    /*
     *until now options
     *provider disponibles:
     *gps (accuracy: ~= 3.41 (m))
     *network (accuracy:~= 14.44(m))
     */
    const options = { provider: "gps" || "network" };
    const position = await Geolocation.getCurrentPosition({ provider: "gps" });
    setMessage(position);
  }
  return (
    <View style={styles.container}>
      <Text style={styles.welcome}>☆Geolocation example☆</Text>
      <Text style={styles.instructions}>STATUS: {status}</Text>
      <Text style={styles.welcome}>☆NATIVE CALLBACK MESSAGE☆</Text>
      <Text style={styles.instructions}>{message}</Text>
      <Button title="Press" onPress={() => getGeolocation()} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: "center",
    alignItems: "center",
    backgroundColor: "#F5FCFF"
  },
  welcome: {
    fontSize: 20,
    textAlign: "center",
    margin: 10
  },
  instructions: {
    textAlign: "center",
    color: "#333333",
    marginBottom: 5
  }
});

Method

NameParamTypevalues
getCurrentPositionoptionobjectprovider

Params

NameKeyValues
optionsprovidernetwork or gps

as soon as possible I will study objective c for implementation thanks to everyone who uses ^^.

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago