1.1.1 • Published 6 years ago
react-native-google-location-fetcher v1.1.1
react-native-google-location-fetcher
Google Location Fetcher for iOS and Android React-Native apps
PLANNED FEATURES
- Get Location Coordinates
- Reverse Geocoding from Google API
- Get Location Name from Google API
- Get any Location Coordinates from Google API
- Ask permission for location on Android
Installation
npm install react-native-google-location-fetcher --save
- Get your Google Places API keys and enable "Google Places API Web Service" (NOT Android or iOS) in the console.
- Enable "Google Maps Geocoding API" if you want to use GoogleReverseGeocoding for Current Location
For Android: add the following line in your AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
Example
import React from 'react';
import { View, Image } from 'react-native';
import {GoogleLocationFetcher} from 'react-native-google-location-fetcher'
export default class App extends Component {
componentWillMount(){
// To initialise the module
GoogleLocationFetcher.initialise(YOUR_API_KEY)
// To get current Location coordinates and name
console.log(GoogleLocationFetcher.getCurrentLocation())
// To get location name from coordinates
console.log(GoogleLocationFetcher.getLocationName(LATITUDE,LONGITUDE))
// TO get location coordinates
console.log(GoogleLocationFetcher.getLocationCoordinates(ANY_LOCATION_NAME))
}
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>Welcome to React Native!</Text>
<Text style={styles.instructions}>To get started, edit App.js</Text>
<Text style={styles.instructions}>{instructions}</Text>
</View>
);
}
}