GeocodeJSON
GeocodeJSON packages are a collection of small utility to work with geocoding API such as Google Geocoding API, HERE Geocoding API, Opencage, etc... As well as self hosted solution like Mimirsbrunn.
These packages provide a simple inteface for geocoding addresses exposing the underlying APIs filtering capabilities while returning all response in a standard format: GeocodeJSON,
a GeoJSON extension.
These packages leverage cross-fetch
to work on both backend & frontend

@p-j/geocodejson-googleapis

Geocode & format to GeocodeJSON using Google Geocoding API
Usage
import { geocode, parse, getFetchArgs } from '@p-j/geocodejson-googleapis'
const { url, options } = getFetchArgs({
apiKey: 'YOUR-GOOGLE-API-KEY-HERE',
address: 'Place de la République, Paris, France',
language: 'fr',
bounds: {
northeast: { lat: 48.8689734302915, lng: 2.3657448 },
southwest: { lat: 48.8662754697085, lng: 2.3622065 },
},
componentRestrictions: { locality: 'Paris', country: 'FR' },
})
const rawResponseFromGoogleApis = await geocode({
apiKey: 'YOUR-GOOGLE-API-KEY-HERE',
address: 'Place de la République, Paris, France',
language: 'fr',
filters: {
bounds: {
northeast: { lat: 48.8689734302915, lng: 2.3657448 },
southwest: { lat: 48.8662754697085, lng: 2.3622065 },
},
componentRestrictions: { locality: 'Paris', country: 'FR' },
},
})
const geocodeJSONFormatedResults = parse(rawResponseFromGoogleApis)