How to use the react-native-get-location.getCurrentPosition function in react-native-get-location

To help you get started, we’ve selected a few react-native-get-location examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github douglasjunior / react-native-get-location / Sample / App.js View on Github external
_requestLocation = () => {
        this.setState({ loading: true, location: null });

        GetLocation.getCurrentPosition({
            enableHighAccuracy: true,
            timeout: 150000,
        })
            .then(location => {
                this.setState({
                    location,
                    loading: false,
                });
            })
            .catch(ex => {
                const { code, message } = ex;
                console.warn(code, message);
                if (code === 'CANCELLED') {
                    Alert.alert('Location cancelled by user or by another request');
                }
                if (code === 'UNAVAILABLE') {

react-native-get-location

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

MIT
Latest version published 4 months ago

Package Health Score

65 / 100
Full package analysis