How to use the geolib.getCenter 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 City-of-Helsinki / open-city-app / src / helpers / map.js View on Github external
export function getPolygonCenter(polygon) {
  let center = geolib.getCenter(polygon);

  center.latitude = Number(center.latitude);
  center.longitude = Number(center.longitude);

  return center;
}
github pelias / openstreetmap / util / geoJsonCenter.js View on Github external
module.exports = function( geometry ){

  var bounds = extent( geometry );

  var center = geolib.getCenter([
    [ bounds[0], bounds[1] ],
    [ bounds[2], bounds[3] ]
  ]);

  if( center.latitude && center.longitude ){
    return { lat: center.latitude, lon: center.longitude };
  }

  return null;
};
github flyandi / react-native-maps-navigation / src / modules / Directions.js View on Github external
},
                instructions: leg.end_address,
            });

            const polylines = steps.map(step => step.polyline);

            const boundingBox = [toCoordinate(route.bounds.northeast), toCoordinate(route.bounds.southwest)];

            return {
                title: route.summary,
                markers,
                steps,
                polylines,
                bounds: {
                    boundingBox,
                    center: GeoLib.getCenter(boundingBox),
                    northEast: toCoordinate(route.bounds.northeast),
                    southWest: toCoordinate(route.bounds.southwest),
                },
                initialBearing: steps.length ? steps[0].bearing : 0,
                duration: leg.duration,
                distance: leg.distance,
                origin: {
                    address: leg.start_address,
                    latlng: leg.start_location,
                    coordinate: toCoordinate(leg.start_location),
                },
                destination: {
                    address: leg.end_address,
                    latlng: leg.end_location,
                    coordinate: toCoordinate(leg.end_location),
                },
github kiwicom / margarita / apps / core / scenes / bookingDetail / sectorDetails / segments / SegmentMap.js View on Github external
render() {
    const locations = this.getMarkerData() ?? [];
    const center = getCenter(this.getMarkerData());
    return (
      
        {locations.map(location => (

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 2 years ago

Package Health Score

58 / 100
Full package analysis

Similar packages