Geocoding has been around since the 1960s as a subset of GIS (Geographic Information System) spatial analysis. The process involves converting a physical address description into a location on the earth’s surface. As an example, “1600 Amphitheatre Parkway, Mountain View, CA” produces the geographic coordinates “37.423021, -122.083739” that can be used for spatial analysis or mapping.
The Google Maps APIs offer two was to perform geocoding, and this tutorial on the Google Maps Blog provides details of both approaches.
Client-side geocoding is usually the most appropriate approach as it executes in the browser, providing a fast response to a user action for an interactive user experience. Requests can also include information such as user language, viewport, and region, to improve geocoding quality. This type of geocoding offers two basic architectures, the first is to geocode in the browser and send it to the server, which allows customising of responses as well as geocode caching.
The second approach is to geocode and display the results entirely in the browser to reduce load on the server. The Google Maps JavaScript API provides classes that make this request for you, and the authors provide a code sample that geocodes an address, centres the map on that location, and adds a map marker on that spot.
HTTP server-side geocoding allows a server to query Google’s servers for geocodes directly via Google Maps Geocoding API. This approach is better suited to applications that must perform geocoding without client input, such as from an existing dataset. This type of geocoding may increase latency for the user, and the results may be less accurate than client-side geocoding since less information is available in the request. The authors provide a code sample of a server-side geocoding request in Python that produces a JSON object, but results can also be output as XML.
Developers looking to use the Google Maps Geocoding API should consider their expected usage to decide which plan to purchase. The Standard Plan imposes daily quotas that impose limits of 2,500 requests per day and a rate limit of 50 queries per second. The premium plan offers higher daily quotas and it consumes quota at different rates depending on the APIs it requests.