@alexpavlov/geohash-js
v1.3.1
Published
JavaScript geocoding library
Downloads
1,150
Readme
GeoHash
Geohash is a public domain geocoding system invented by Gustavo Niemeyer, which encodes a geographic location into a short string of letters and digits. It is a hierarchical spatial data structure which subdivides space into buckets of grid shape, which is one of the many applications of what is known as a Z-order curve, and generally space-filling curves.
Geohashes offer properties like arbitrary precision and the possibility of gradually removing characters from the end of the code to reduce its size (and gradually lose precision). As a consequence of the gradual precision degradation, nearby places will often (but not always) present similar prefixes. The longer a shared prefix is, the closer the two places are.
Read more on Wikipedia.
Usage
Standalone version
Include geohash.min.js which you can find in the build folder.
<script src="dist/geohash-js/geohash.min.js"></script>
Now you can use library
var hashedValue = geohash.encode(52.372518, 4.896977);
Usage as module
Installation
With npm
$ npm install @alexpavlov/geohash-js
or with yarn
$ yarn add @alexpavlov/geohash-js
Add to your module
CommonJS
var encode = require('@alexpavlov/geohash-js').encode;
var hashedValue = encode(52.372518, 4.896977);
ES2015
import { encode } from '@alexpavlov/geohash-js';
let hashedValue = encode(52.372518, 4.896977);