How to use the react-native-background-geolocation.getLocations function in react-native-background-geolocation

To help you get started, weโ€™ve selected a few react-native-background-geolocation 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 devnowcafe / runx / src / screens / Home / index.js View on Github external
timeDiff = (new Date().getTime() - timeStart) / 1000;
                        this._interval = setInterval(() => {
                            this.setState({ runningDuration: this.state.runningDuration + 1 })
                        }, 1000);
                        break;
                    case "paused":
                        timeDiff = (new Date(runState.pauseAt).getTime() - timeStart) / 1000;
                        break;
                    case "finished":
                        timeDiff = (new Date(runState.finishAt).getTime() - timeStart) / 1000;

                        break;
                }

                const distance = await BackgroundGeolocation.getOdometer();
                const locations = await BackgroundGeolocation.getLocations();
                let coordinates = [];
                let markers = [...this.state.markers];
                if (locations.length) {
                    _.forEach(locations, (item) => {
                        coordinates.push({ latitude: item.coords.latitude, longitude: item.coords.longitude })
                    })
                    markers = [{
                        key: locations[0].uuid,
                        title: locations[0].timestamp,
                        heading: locations[0].coords.heading,
                        coordinate: {
                            latitude: locations[0].coords.latitude,
                            longitude: locations[0].coords.longitude
                        }
                    }]
                }