Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

geokit

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geokit

An assortment of geolocation related tools, all packaged in one easy to use kit.

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.1K
decreased by-6.96%
Maintainers
1
Weekly downloads
 
Created
Source

Geokit Build Status npm version

An assortment of geolocation related tools, all packaged in one easy to use kit.

Methods

Geokit.distance(start: LatLngLiteral, end: LatLngLiteral, unit?: string): number

Static method which returns the distance, in kilometers, between start and end.

start and end must be LatLngLiterals { lat: 0, lng: 0 }.

There exists an optional third argument, where if the string 'miles' is inputted, the result returned will be in miles rather than kilometers.

import { Geokit, LatLngLiteral } from 'geokit';

const start: LatLngLiteral = { lat: 40.7128,  lng: -74.0060 };
const end: LatLngLiteral = { lat: 37.7749,  lng: -122.4194 };

const distance: number = Geokit.distance(location1, location2, 'miles');  // distance === 2568.4458439997047

Geokit.hash(coordinates: LatLngLiteral, precision?: number): string

Static method which generates the geohash of a point.

coordinates must be LatLngLiterals { lat: 0, lng: 0 }.

There exists an optional second argument of precision, where the hash produced will be as many characters as the number inputted. It defaults to 10.

import { Geokit, LatLngLiteral } from 'geokit';

const coordinates: LatLngLiteral = { lat: 41.3083,  lng: -72.9279 };

const hash: string = Geokit.hash(coordinates);  // hash === 'drk4urzw2c'

Geokit.decodeHash(hash: string): LatLngLiteral

Static method which decodes geohash into its Latitude and Longitude as a LatLngLiteral.

import { Geokit, LatLngLiteral } from 'geokit';

const hash: string = 'r3gx2f77b';

const coordinates: LatLngLiteral = Geokit.decodeHash(hash);  // coordinates === { lat: -33.86881113052368,  lng: 151.2093186378479 }

Keywords

FAQs

Package last updated on 02 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc