HTML and CSS Reference
In-Depth Information
8.3 Reverse Geocoding an Address with Latitude and Longitude
Problem
You want to convert latitude and longitude coordinates into a human-friendly address.
Solution
Use the Google Maps JavaScript API to turn latitude and longitude into an address, as
shown in
Figure 8-2
.
Figure 8-2. Determining a user's address based on latitude and longitude
The process of turning geographic data like a street address and zip code into geo-
graphic coordinates such as latitude and longitude is called
geocoding
(we'll get to this
in the next recipe). Doing the opposite, turning coordinates into an address, is called
reverse geocoding
.
Begin by adding the needed scripts to your web page:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.js">
</script>
<script src="http://j.maxmind.com/app/geoip.js"></script>
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>