How to use the geolib.getBearing function in geolib

To help you get started, we’ve selected a few geolib 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 flyandi / react-native-maps-navigation / src / modules / Simulator.js View on Github external
points.forEach((point, index) => {

            const nextPoint = points[index + 1];

            if(nextPoint && !nextPoint.final == true) {

                // calculate distance between each point
                const distance = Math.round(GeoLib.getDistance(point, nextPoint));
                const bearing =  GeoLib.getBearing(point, nextPoint);

                if(bearing !== 0) {

                    if (distance > 1) {

                        for (var x = 1; x < distance; x++) {

                            result.push(Object.assign({}, {bearing}, GeoLib.computeDestinationPoint(point, x, bearing)));
                        }

                    } else {
                        result.push(Object.assign({}, {bearing}, point));
                    }
                }
            }
        });
github Mindinventory / Map-interaction-prototype / App.js View on Github external
if (this.state.latitudeDestination !== LATITUDE_DEST1) {
            this.setState({

                latitudeDestination: LATITUDE_DEST1,
                longitudeDestination: LONGITUDE_DEST1
            })
        }
        else {
            this.setState({

                latitudeDestination: LATITUDE_DEST2,
                longitudeDestination: LONGITUDE_DEST2
            })
        }

        let bearing = geolib.getBearing(
            {latitude: LATITUDE, longitude: LONGITUDE},
            {latitude: this.state.latitudeDestination, longitude: this.state.longitudeDestination}
        );

        this.animate();

        return bearing;
    }
github flyandi / react-native-maps-navigation / src / modules / Directions.js View on Github external
parseStep(step, nextStep) {

        const bearing = GeoLib.getBearing(toCoordinate(step.start_location), toCoordinate(nextStep ? nextStep.start_location : step.end_location));

        return {
            compass: this.decodeCompass(bearing),
            maneuver: this.decodeManeuver(step, bearing),
            bearing: bearing,
            mode: step.travel_mode,
            start: toCoordinate(step.start_location),
            end: toCoordinate(step.end_location),
            polyline: {
                coordinates: this.decodePolylineToCoordinates(step.polyline.points),
                type: PolylineTypes.ROUTE,
            },
            duration: step.duration,
            distance: step.distance,
            instructions: step.html_instructions,
        }
github Mindinventory / Map-interaction-prototype / app / screens / MapScreen.js View on Github external
if (this.state.latitudeDestination !== LATITUDE_DEST1) {
            this.setState({

                latitudeDestination: LATITUDE_DEST1,
                longitudeDestination: LONGITUDE_DEST1
            })
        }
        else {
            this.setState({

                latitudeDestination: LATITUDE_DEST2,
                longitudeDestination: LONGITUDE_DEST2
            })
        }

        let bearing = geolib.getBearing(
            {latitude: LATITUDE, longitude: LONGITUDE},
            {latitude: this.state.latitudeDestination, longitude: this.state.longitudeDestination}
        );

        this.animate();

        return bearing;
    }

geolib

Library to provide basic geospatial operations like distance calculation, conversion of decimal coordinates to sexagesimal and vice versa, etc. This library is currently **2D**, meaning that altitude/elevation is not yet supported by any of its functions!

MIT
Latest version published 12 months ago

Package Health Score

78 / 100
Full package analysis

Similar packages