Exciting news!Announcing our $4.6M Series Seed. Learn more
Socket
LoveBlogFAQ
Install
Log in

@goparrot/react-native-geometry-utils

Package Overview
Dependencies
0
Maintainers
2
Versions
2
Issues
File Explorer

Advanced tools

@goparrot/react-native-geometry-utils

Google maps geometry utils for react native

    0.2.0latest

Version published
Maintainers
2
Yearly downloads
5,549
increased by125.75%

Weekly downloads

Readme

Source

@goparrot/react-native-geometry-utils

Google maps geometry utils for react native

This library is a clone of react-native-geo-fencing with several improvements.

Installation

npm install @goparrot/react-native-geometry-utils

Usage

import { polygonContainsLocation, circleContainsLocation, computeDistanceBetween } from "@goparrot/react-native-geometry-utils"; // ... const polygon = [ { latitude: 0, longitude: 0 }, { latitude: 0, longitude: 1 }, { latitude: 1, longitude: 1 }, { latitude: 1, longitude: 0 }, { latitude: 0, longitude: 0 }, // last point has to be same as first point ]; const cicle = { center: { latitude: 0, longitude: 0, }, radius: 15742.949, // approximate radius of 0.1 degree in meters }; const pointIn = { latitude: 0.1, longitude: 0.1, }; const pointOut = { latitude: 0.2, longitude: -0.2, }; await polygonContainsLocation(pointIn, polygon); // true await polygonContainsLocation(pointOut, polygon); // false await circleContainsLocation(pointIn, cicle); // true await circleContainsLocation(pointOut, cicle); // false await computeDistanceBetween(pointIn, pointOut); // 35162.86 meters

API

Interfaces

interface LatLng { latitude: number; longitude: number; } interface Circle { center: LatLng; radius: number; }

Functions

polygonContainsLocation(point: LatLng, polygon: LatLng[]): Promise<boolean>; circleContainsLocation(point: LatLng, circle: Circle): Promise<boolean>; computeDistanceBetween(from: LatLng, to: LatLng): Promise<number>;

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

Keywords

Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc