MichaelSolati / geofirestore-js

Location-based querying and filtering using Firebase Firestore.

Home Page:https://geofirestore.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Documentation on how to create geohash yourself

fabyeah opened this issue · comments

I'm using geocollection.add to create new documents, but editing happens inside a cloud function, so I'd like to pass a geohash to it, so the required data structure can be created there. Would be great if the README included info on how to create a geohash from latlng yourself with the included tools.

How do I do that?

I'm using the latlon-geohash package now for that, but I assume this functionality is already included in geofirestore. Is it accessible?

So the point of the library isn't quite to surface the "magic" of geohashes, it's designed to simplify the add/query experience for you. However it has a dependency called geofirestore-core which give you a more bare bone library, and geofirestore-core requires geokit which is what hashes the coordinates.

So if you have geofirestore installed, geokit should be installed as a dependency, and you can use it to hash a coordinate like...

import * as geokit from 'geokit';

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

const hash = geokit.hash(coordinates); // hash === 'drk4urzw2c'

Thanks, that works! 👍