Home > front end >  Latitude Longitude = city name, React JS
Latitude Longitude = city name, React JS

Time:10-12

I'm building a React weather app with an API that only accepts a Latitude and Longitude, not a city name. I'm new to React and am wondering if there's a way to transform the user input (City name) to latitude and longitude so I can call the api.

Thank you!

CodePudding user response:

You should try a geolocation package or api like this one for example: https://www.npmjs.com/package//react-geocode

They've already done the busy work of figuring out that conversion for you.

CodePudding user response:

There are few other Apis I have used for weather applications which use city name to fetch weather data along with latitude and longitude.you can take a look if it serves your purpose.

  1. Open weather map api

  2. Accu weather Api

  • Related