Mapping latitude and longitude to country, state, or city
Published on: 2025-06-11 10:13:01
Austin Z. Henley Associate Teaching Professor
Carnegie Mellon University [email protected]
@austinzhenley
github/AZHenley
Mapping latitude and longitude to country, state, or city
6/3/2025
See the discussion of this post on Hacker News.
An app can easily check a user's location (with permission), but figuring out where that location is, is far more difficult. For example, a web app can use geolocation.getCurrentPosition() to get a user's location in the form of latitude and longitude coordinates. But how do you convert coordinates to country, state, or city? Well, you have to look it up, somehow. (I later learned this is called reverse geocoding.)
At the startup I worked at, we paid several thousands of dollars per year for the Google Maps API to do a reverse lookup (that decision was made long before I joined). Given the coordinates, it gave us back a full address. We only cared about the state they were in, so we ignored the rest. If the user didn't allow us to check their l
... Read full article.