pluscodes
TypeScript icon, indicating that this package has built-in type declarations

2.6.0 • Public • Published

Overview

Implementation of plus codes in Javascript/Typescript. See a description with running code at Runkit.

Usage

Diagram

Encoding

const { encode } = require('pluscodes')
encode({ latitude: 59.332438, longitude: 18.118813 }) // '9FFW84J9+XG'
encode({ latitude: 59.332438, longitude: 18.118813 }, 8) // '9FFW84J9+'
encode({ latitude: 59.332438, longitude: 18.118813 }, 4) // '9FFW0000+'

Decoding

const { decode } = require('pluscodes')
decode('9FFW84J9+XG') // { latitude: 59.332438, longitude: 18.118813, resolution: 0.000125 }
decode('9FFW84J9+') // { latitude: 59.331250, longitude: 18.118750, resolution: 0.0025 }
decode('9FFW0000+') // { latitude: 59.500000, longitude: 18.500000, resolution: 1 }

Shortening codes

const { shorten } = require('pluscodes')
shorten('9FFW84J9+XG', { latitude: 59.329394, longitude: -162.068712 }) // '9FFW84J9+XG'
shorten('9FFW84J9+XG', { latitude: 59.329394, longitude: 18.068712 }) // '84J9+XG'
shorten('9FFW84J9+XG', { latitude: 59.332438, longitude: 18.118813 }) // 'J9+XG'

Expanding short codes

const { expand } = require('pluscodes')
expand('FW84J9+XG', { latitude: 59.329394, longitude: 18.068712 }) // '9FFW84J9+XG'
expand('84J9+XG', { latitude: 59.329394, longitude: 18.068712 }) // '9FFW84J9+XG'
expand('J9+XG', { latitude: 59.329394, longitude: 18.068712 }) // '9FFW83J9+XG'

Author

Jan Andersson, jan.andersson@gmail.com

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.6.0330latest

Version History

VersionDownloads (Last 7 Days)Published
2.6.0330
2.5.162
2.5.00
2.4.00
2.3.00
2.2.00
2.1.00
2.0.30
2.0.23
2.0.10
2.0.00
1.2.20
1.2.10
1.2.00
1.1.10
1.1.00
1.0.00

Package Sidebar

Install

npm i pluscodes

Weekly Downloads

395

Version

2.6.0

License

MIT

Unpacked Size

43.1 kB

Total Files

39

Last publish

Collaborators

  • jan_andersson