javascriptgeocodeturfjs

How to geocode with TurfJS with lat/long?


How can I get the location details / geocode with TurfJS? I want to simply give it a lat/long and get back the country, state, zipcode, etc...

I checked their online documentation but didn't see a clear way to do this...?

Something like below...

const turf = require("@turf/turf")

const lat = 51.50998

const long = -0.13375

const details = turf.geocode(lat,long)

console.log(details) 


Solution

  • That isn't possible within Turf. Closest you could probably get is having the state geometries on hand, and doing a booleanPointInPolygon.

    But really, you're looking for something more like the Mapbox geocoding API