How to use the geolib.getBounds 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 kiwicom / mobile / app / hotels / src / map / allHotels / MapView.js View on Github external
// Use median to filter out extreme positions to compute more appropriate region
    const lowMiddle = Math.floor((distances.length - 1) / 2);
    const highMiddle = Math.ceil((distances.length - 1) / 2);
    const median = (distances[lowMiddle].distance + distances[highMiddle].distance) / 2;
    const validDistances =
      distances.length > 2
        ? distances
            .filter(({ distance }) => median * 1.5 > distance)
            .slice(0, NO_OF_MARKERS_IN_REGION)
        : distances;

    const coordsByDistance = validDistances
      .map(({ key }) => coordinates[parseInt(key, 10)])
      .filter(Boolean);
    const boundaries = getBounds(coordsByDistance);
    const latitudeDelta = boundaries.maxLat - boundaries.minLat;
    const longitudeDelta = boundaries.maxLng - boundaries.minLng;

    return { longitudeDelta, latitudeDelta };
  };

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 1 year ago

Package Health Score

66 / 100
Full package analysis

Similar packages