Sprockets is a Java library that provides a Java interface for the Google Places, Google Street View Image and Google Distance Matrix APIs.
- Features
- Download and Configure
- Javadoc
Full support for Place Search, Details, Photos, Autocomplete, and Query Autocomplete requests, including all parameters and returned fields. Getting a list of places can be as simple as:
Places.textSearch(new Params().query("pizza near willis tower")).getResult();
More detailed searches can include lat/long with radius, specific types of places, keywords, price range, places that are open now, etc. For each returned place, you can also retrieve its full details, reviews, photos, and events.
The Google Places API can return a lot of information about each place and most of the time you probably won't need every detail. For maximum performance and minimum memory usage, you can specify which fields you want and limit the number of results.
Places.nearbySearch(new Params().location(47.60567, -122.3315).radius(5000)
.keyword("swimming").openNow().maxResults(5),
NAME, VICINITY, RATING, PHOTOS).getResult();
Download a Google Street View Image by supplying a lat/long or location name.
StreetView.image(new Params().location("18 Rue Cujas, Paris, France")).getResult();
For fine control of the camera, you can also specify the heading, pitch, and field of view.
StreetView.image(new Params().location(40.748769, -73.985332)
.heading(210).pitch(33).fov(110)).getResult();
Query the Google Distance Matrix API to get durations and distances between multiple locations
DistanceMatrix.distances(new Params().origin(48.2116039, 16.37701)
.destinations("Staatsoper in Wien, Austria", "Rathaus in Wien, Austria")
.mode("waling")).getResults();