Java Reference
In-Depth Information
Each constructor sets the name of the stadium, as well as its city , state , and the three-
letter team abbreviation. What are missing are the latitude and longitude values.
TosupplythoseIusetheGooglegeocoder,whichisanotherRESTfulwebserviceprovided
by Google, similar to the Google Chart API discussed in the previous section.
POGO
Plain Old Groovy Objects are like POJOs, but with auto-generated getters, setters, and
map-based constructors.
Geocoding
The Google Geocoding API is documented at https://developers.google.com/maps/docu-
mentation/geocoding/ . A geocoder transforms an address into a latitude and longitude. To
use the Google geocoder you need to assemble a URL that includes the address informa-
tion. According to the documentation, the URL has the form
http://maps.googleapis.com/maps/api/geocode/output?parameters
Here the value of output is either xml or json , depending on which type of data you
want back. [ 5 ] The parameters property contains the address, as well as a sensor
value. Here's the sample from the documentation, which (naturally enough) uses the ad-
dress of Google's headquarters in Mountain View, CA:
5 True REST advocates prefer that content negotiation be done in an Accept header on the HTTP request. Here
Google does it through separate URIs.
http://maps.googleapis.com/maps/api/geocode/
xml?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor= true_or_
false
If you intend to access the geocoder using JavaScript, I would say to use json (JavaScript
Object Notation) for the output value. Because I'm working with Groovy, and Groovy
works well with XML, I'll use the xml value. The query string contains two parameters.
The first is the address, which holds URL-encoded values of the street, city, and state (sep-
arated by “,”) . The other parameter is called sensor , whose value is true if the request
is coming from a GPS-enabled device and false otherwise.
I'll start the geocoding process by setting a variable to the base URL:
 
Search WWH ::




Custom Search