Google Maps: Geocoding

Geocoding is the process of converting addresses (like “1600 Amphitheatre Parkway, Mountain View, CA”) into geographic coordinates (like latitude 37.423021 and longitude -122.083739), which you can use to place markers or position the map. The Google Maps API Geocoding Service provides a direct way to access a geocoder via an HTTP request.

Geocoding Requests
You may access the Google Maps API Geocoding Service directly over HTTP. To access the geocoder, send a request to http://maps.google.com/maps/geo? with the following parameters in the URL:

  • q (required) – The address that you want to geocode. Note that this address must be encoded in UTF-8
  • sensor (required) – Indicates whether or not the geocoding request comes from a device with a location sensor. This value must be either true or false
  • output (required) – The format in which the output should be generated. The options are xml, kml, csv, or (default) json.
  • ll (optional) – The {latitude,longitude} of the viewport center expressed as a comma-separated string (e.g. “ll=40.479581,-117.773438” ). This parameter only has meaning if the spn parameter is also passed to the geocoder.
  • spn (optional) – The “span” of the viewport expressed as a comma-separated string of {latitude,longitude} (e.g. “spn=11.1873,22.5” ). This parameter only has meaning if the ll parameter is also passed to the geocoder
  • gl (optional) – The country code, specified as a ccTLD (“top-level domain”) two-character value

Leave a Reply