Image missing.
Mapping latitude and longitude to country, state, or city

created: June 3, 2025, 10:13 p.m. | updated: June 4, 2025, 5:14 p.m.

Austin Z. Henley Associate Teaching ProfessorCarnegie Mellon University [email protected]@austinzhenleygithub/AZHenleyMapping latitude and longitude to country, state, or city6/3/2025See the discussion of this post on Hacker News. For example, a web app can use geolocation.getCurrentPosition() to get a user's location in the form of latitude and longitude coordinates. It is a single-file JavaScript library with no dependencies that can run client-side to determine which state a given latitude and longitude point falls in. I downloaded the state borders from 2024, which came in a 50 MB binary file detailing the vectors of each border. Based on your use case, you'll need to handle the case of the point not being within any state borders.

4 days, 13 hours ago: Hacker News