Geocoding with PHP and the Google Maps API
Performing a Geocoder Request
When you perform a geocoder request, you can specify which output type to use. The available options are JSON, XML, KML and CSV. In this article we will be requesting and handling XML data.
To perform a geocoder request, a HTTP get request is sent to
http://maps.google.com/maps/geo. There are three URI parameters that must be specified in this request:
qThe address or location that you want to geocoded.
keyThis is the Google Maps API key that you created earlier in this article.
outputThis the output format for the response (as discussed above). The values that can be used are
For example, if you wanted to find the coordinates of The White House (located at 1600 Pennsylvania Avenue, Washington, DC), you would request the following URL:
The precise address string you send in the query is not critical it simply needs enough data in it to identify the location you're after (that is, it should not be ambiguous).