public class GooglePlaces extends Object implements GooglePlacesInterface
API_URL, ARRAY_ADDRESS_COMPONENTS, ARRAY_ALT_IDS, ARRAY_ASPECTS, ARRAY_MATCHED_SUBSTRINGS, ARRAY_PERIODS, ARRAY_PHOTOS, ARRAY_PREDICTIONS, ARRAY_RESULTS, ARRAY_REVIEWS, ARRAY_TERMS, ARRAY_TYPES, BOOLEAN_OPENED, DEFAULT_RESULTS, DOUBLE_LATITUDE, DOUBLE_LONGITUDE, DOUBLE_RATING, INTEGER_ACCURACY, INTEGER_DAY, INTEGER_HEIGHT, INTEGER_LENGTH, INTEGER_OFFSET, INTEGER_PRICE_LEVEL, INTEGER_RATING, INTEGER_UTC_OFFSET, INTEGER_WIDTH, LONG_TIME, MAX_PHOTO_SIZE, MAXIMUM_PAGE_RESULTS, MAXIMUM_RADIUS, MAXIMUM_RESULTS, METHOD_ADD, METHOD_AUTOCOMPLETE, METHOD_DELETE, METHOD_DETAILS, METHOD_NEARBY_SEARCH, METHOD_QUERY_AUTOCOMPLETE, METHOD_RADAR_SEARCH, METHOD_TEXT_SEARCH, OBJECT_CLOSE, OBJECT_GEOMETRY, OBJECT_HOURS, OBJECT_LOCATION, OBJECT_OPEN, OBJECT_RESULT, STRING_ADDRESS, STRING_AUTHOR_NAME, STRING_AUTHOR_URL, STRING_DESCRIPTION, STRING_ERROR_MESSAGE, STRING_ICON, STRING_INTERNATIONAL_PHONE_NUMBER, STRING_LANGUAGE, STRING_LONG_NAME, STRING_NAME, STRING_NEXT_PAGE_TOKEN, STRING_PHONE_NUMBER, STRING_PHOTO_REFERENCE, STRING_PLACE_ID, STRING_SCOPE, STRING_SHORT_NAME, STRING_STATUS, STRING_TEXT, STRING_TIME, STRING_TYPE, STRING_TYPES, STRING_URL, STRING_VALUE, STRING_VICINITY, STRING_WEBSITETYPE_ACCOUNTING, TYPE_AIRPORT, TYPE_AMUSEMENT_PARK, TYPE_AQUARIUM, TYPE_ART_GALLERY, TYPE_ATM, TYPE_BAKERY, TYPE_BANK, TYPE_BAR, TYPE_BEAUTY_SALON, TYPE_BICYCLE_STORE, TYPE_BOOK_STORE, TYPE_BOWLING_ALLEY, TYPE_BUS_STATION, TYPE_CAFE, TYPE_CAMPGROUND, TYPE_CAR_DEALER, TYPE_CAR_RENTAL, TYPE_CAR_REPAIR, TYPE_CAR_WASH, TYPE_CASINO, TYPE_CEMETERY, TYPE_CHURCH, TYPE_CITY_HALL, TYPE_CLOTHING_STORE, TYPE_CONVENIENCE_STORE, TYPE_COURTHOUSE, TYPE_DENTIST, TYPE_DEPARTMENT_STORE, TYPE_DOCTOR, TYPE_ELECTRICIAN, TYPE_ELECTRONICS_STORE, TYPE_EMBASSY, TYPE_ESTABLISHMENT, TYPE_FINANCE, TYPE_FIRE_STATION, TYPE_FLORIST, TYPE_FOOD, TYPE_FUNERAL_HOME, TYPE_FURNITURE_STORE, TYPE_GAS_STATION, TYPE_GENERAL_CONTRACTOR, TYPE_GROCERY_OR_SUPERMARKET, TYPE_GYM, TYPE_HAIR_CARE, TYPE_HARDWARE_STORE, TYPE_HEALTH, TYPE_HINDU_TEMPLE, TYPE_HOME_GOODS_STORE, TYPE_HOSPITAL, TYPE_INSURANCE_AGENCY, TYPE_JEWELRY_STORE, TYPE_LAUNDRY, TYPE_LAWYER, TYPE_LIBRARY, TYPE_LIQUOR_STORE, TYPE_LOCAL_GOVERNMENT_OFFICE, TYPE_LOCKSMITH, TYPE_LODGING, TYPE_MEAL_DELIVERY, TYPE_MEAL_TAKEAWAY, TYPE_MOSQUE, TYPE_MOVIE_RENTAL, TYPE_MOVIE_THEATER, TYPE_MOVING_COMPANY, TYPE_MUSEUM, TYPE_NIGHT_CLUB, TYPE_PAINTER, TYPE_PARK, TYPE_PARKING, TYPE_PET_STORE, TYPE_PHARMACY, TYPE_PHYSIOTHERAPIST, TYPE_PLACE_OF_WORSHIP, TYPE_PLUMBER, TYPE_POLICE, TYPE_POST_OFFICE, TYPE_REAL_ESTATE_AGENCY, TYPE_RESTAURANT, TYPE_ROOFING_CONTRACTOR, TYPE_RV_PARK, TYPE_SCHOOL, TYPE_SHOE_STORE, TYPE_SHOPPING_MALL, TYPE_SPA, TYPE_STADIUM, TYPE_STORAGE, TYPE_STORE, TYPE_SUBWAY_STATION, TYPE_SYNAGOGUE, TYPE_TAXI_STAND, TYPE_TRAIN_STATION, TYPE_TRAVEL_AGENCY, TYPE_UNIVERSITY, TYPE_VETERINARY_CARE, TYPE_ZOOSTATUS_INVALID_REQUEST, STATUS_NOT_FOUND, STATUS_OK, STATUS_OVER_QUERY_LIMIT, STATUS_REQUEST_DENIED, STATUS_UNKNOWN_ERROR, STATUS_ZERO_RESULTS| Constructor and Description |
|---|
GooglePlaces(String apiKey)
Creates a new GooglePlaces object using the specified API key.
|
GooglePlaces(String apiKey,
RequestHandler requestHandler)
Creates a new GooglePlaces object using the specified API key and the specified
RequestHandler. |
GooglePlaces(String apiKey,
String characterEncoding)
Creates a new GooglePlaces object using the specified API key and character encoding.
|
| Modifier and Type | Method and Description |
|---|---|
Place |
addPlace(PlaceBuilder builder,
boolean returnPlace,
Param... extraParams)
Adds a new place to the Places API and gets the newly created place if returnPlace is set to true.
|
protected static void |
checkStatus(String statusCode,
String errorMessage) |
void |
deletePlace(Place place,
Param... extraParams)
Deletes the specified place.
|
void |
deletePlaceById(String placeId,
Param... extraParams)
Deletes the place of the specified placeId.
|
protected InputStream |
download(String uri) |
protected InputStream |
downloadPhoto(Photo photo,
int maxWidth,
int maxHeight,
Param... extraParams) |
String |
getApiKey()
Returns the API key associated with this GooglePlaces object.
|
List<Place> |
getNearbyPlaces(double lat,
double lng,
double radius,
int limit,
Param... extraParams)
Returns the places at the specified latitude and longitude within the specified radius.
|
List<Place> |
getNearbyPlaces(double lat,
double lng,
double radius,
Param... extraParams)
Returns the places at the specified latitude and longitude within the specified radius.
|
List<Place> |
getNearbyPlacesRankedByDistance(double lat,
double lng,
int limit,
Param... params)
Returns the places at the specified latitude and longitude in order of proximity to the specified location.
|
List<Place> |
getNearbyPlacesRankedByDistance(double lat,
double lng,
Param... params)
Returns the places at the specified latitude and longitude in order of proximity to the specified location.
|
Place |
getPlaceById(String placeId,
Param... extraParams)
Returns the place specified by the 'placeid'.
|
List<Prediction> |
getPlacePredictions(String input,
int offset,
int lat,
int lng,
int radius,
Param... extraParams)
Returns a list of auto-complete predictions for searching for a specific place.
|
List<Prediction> |
getPlacePredictions(String input,
int offset,
Param... extraParams)
Returns a list of auto-complete predictions for searching for a specific place.
|
List<Prediction> |
getPlacePredictions(String input,
Param... extraParams)
Returns a list of auto-complete predictions for searching for a specific place.
|
List<Place> |
getPlacesByQuery(String query,
int limit,
Param... extraParams)
Returns the places that match the specified search query.
|
List<Place> |
getPlacesByQuery(String query,
Param... extraParams)
Returns the places that match the specified search query.
|
List<Place> |
getPlacesByRadar(double lat,
double lng,
double radius,
int limit,
Param... extraParams)
Returns the places at the specified latitude and longitude according to the "radar" method specified by Google
Places API.
|
List<Place> |
getPlacesByRadar(double lat,
double lng,
double radius,
Param... extraParams)
Returns the places at the specified latitude and longitude according to the "radar" method specified by Google
Places API.
|
List<Prediction> |
getQueryPredictions(String input,
int offset,
int lat,
int lng,
int radius,
Param... extraParams)
Returns a list of auto-complete predictions for searching for a place by a query.
|
List<Prediction> |
getQueryPredictions(String input,
int offset,
Param... extraParams)
Returns a list of auto-complete predictions for searching for a place by a query.
|
List<Prediction> |
getQueryPredictions(String input,
Param... extraParams)
Returns a list of auto-complete predictions for searching for a place by a query.
|
RequestHandler |
getRequestHandler()
Returns the interface that handles HTTP requests to Google's server.
|
boolean |
isDebugModeEnabled()
Returns true if the client is running in debug mode.
|
static String |
parse(GooglePlaces client,
List<Place> places,
String str,
int limit)
Parses the specified raw json String into a list of places.
|
void |
setApiKey(String apiKey)
Sets the API key associated with this GooglePlaces object.
|
void |
setDebugModeEnabled(boolean debugModeEnabled)
Sets if the client should run in debug mode.
|
void |
setRequestHandler(RequestHandler requestHandler)
Sets the request handler to delegate HTTP traffic.
|
public GooglePlaces(String apiKey, RequestHandler requestHandler)
RequestHandler.apiKey - that has been registered on the Google Developer ConsolerequestHandler - to handle HTTP trafficpublic GooglePlaces(String apiKey)
apiKey - that has been registered on the Google Developer Consolepublic GooglePlaces(String apiKey, String characterEncoding)
apiKey - that has been registered on the Google Developer ConsolecharacterEncoding - to parse data withpublic static String parse(GooglePlaces client, List<Place> places, String str, int limit)
places - to parse intostr - raw jsonlimit - the maximum amount of places to returnpublic boolean isDebugModeEnabled()
GooglePlacesInterfaceisDebugModeEnabled in interface GooglePlacesInterfacepublic void setDebugModeEnabled(boolean debugModeEnabled)
GooglePlacesInterfacesetDebugModeEnabled in interface GooglePlacesInterfacedebugModeEnabled - true if in debug modepublic String getApiKey()
GooglePlacesInterfacegetApiKey in interface GooglePlacesInterfacepublic void setApiKey(String apiKey)
GooglePlacesInterfacesetApiKey in interface GooglePlacesInterfaceapiKey - to setpublic RequestHandler getRequestHandler()
GooglePlacesInterfacegetRequestHandler in interface GooglePlacesInterfacepublic void setRequestHandler(RequestHandler requestHandler)
GooglePlacesInterfacesetRequestHandler in interface GooglePlacesInterfacerequestHandler - to handle HTTP trafficpublic List<Place> getNearbyPlaces(double lat, double lng, double radius, int limit, Param... extraParams)
GooglePlacesInterfaceGooglePlacesInterface.MAXIMUM_PAGE_RESULTS, multiple HTTP GET requests may be made if necessary.getNearbyPlaces in interface GooglePlacesInterfacelat - latitudelng - longituderadius - radiuslimit - the maximum amount of places to returnextraParams - any extra parameters to include in the request URLpublic List<Place> getNearbyPlaces(double lat, double lng, double radius, Param... extraParams)
GooglePlacesInterfaceGooglePlacesInterface.DEFAULT_RESULTS will be returned and no more than one HTTP GET request will be sent.getNearbyPlaces in interface GooglePlacesInterfacelat - latitudelng - longituderadius - radiusextraParams - any extra parameters to include in the request URLpublic List<Place> getNearbyPlacesRankedByDistance(double lat, double lng, int limit, Param... params)
GooglePlacesInterfaceGooglePlacesInterface.MAXIMUM_PAGE_RESULTS, multiple HTTP GET requests may be made if
necessary. One or more of the parameters 'keyword', 'name', or 'types' is required or else a
GooglePlacesException will be thrown.getNearbyPlacesRankedByDistance in interface GooglePlacesInterfacelat - latitudelng - longitudelimit - the maximum amount of places to returnparams - parameters to append to url, one or more being 'keyword', 'name', or 'types'public List<Place> getNearbyPlacesRankedByDistance(double lat, double lng, Param... params)
GooglePlacesInterfaceGooglePlacesInterface.DEFAULT_RESULTS will be returned and no more than one HTTP GET request will be sent. One or
more of the parameters 'keyword', 'name', or 'types' is required or else a
GooglePlacesException will be thrown.getNearbyPlacesRankedByDistance in interface GooglePlacesInterfacelat - latitudelng - longitudeparams - parameters to append to url, one or more being 'keyword', 'name', or 'types'public List<Place> getPlacesByQuery(String query, int limit, Param... extraParams)
GooglePlacesInterfaceGooglePlacesInterface.MAXIMUM_PAGE_RESULTS, multiple HTTP GET requests may be made if necessary.getPlacesByQuery in interface GooglePlacesInterfacequery - search querylimit - the maximum amount of places to returnextraParams - any extra parameters to include in the request URLpublic List<Place> getPlacesByQuery(String query, Param... extraParams)
GooglePlacesInterfaceGooglePlacesInterface.DEFAULT_RESULTS will be returned
and no more than one HTTP GET request will be sent. The 'sensor' parameter defaults to false.getPlacesByQuery in interface GooglePlacesInterfacequery - search queryextraParams - any extra parameters to include in the request URLpublic List<Place> getPlacesByRadar(double lat, double lng, double radius, int limit, Param... extraParams)
GooglePlacesInterfaceGooglePlacesInterface.MAXIMUM_PAGE_RESULTS, multiple HTTP GET requests
may be made if necessary.getPlacesByRadar in interface GooglePlacesInterfacelat - latitudelng - longituderadius - radiuslimit - the maximum amount of places to returnextraParams - any extra parameters to include in the request URLpublic List<Place> getPlacesByRadar(double lat, double lng, double radius, Param... extraParams)
GooglePlacesInterfaceGooglePlacesInterface.DEFAULT_RESULTS will be returned and no more than one HTTP GET request will
be sent.getPlacesByRadar in interface GooglePlacesInterfacelat - latitudelng - longituderadius - radiusextraParams - any extra parameters to include in the request URLpublic Place getPlaceById(String placeId, Param... extraParams)
GooglePlacesInterfacegetPlaceById in interface GooglePlacesInterfaceplaceId - to getextraParams - params to append to urlpublic Place addPlace(PlaceBuilder builder, boolean returnPlace, Param... extraParams)
GooglePlacesInterfaceaddPlace in interface GooglePlacesInterfacebuilder - to get place details fromreturnPlace - true if the newly created place should be returnedextraParams - to append to request urlpublic void deletePlaceById(String placeId, Param... extraParams)
GooglePlacesInterfacedeletePlaceById in interface GooglePlacesInterfaceplaceId - place idextraParams - params to append to urlpublic void deletePlace(Place place, Param... extraParams)
GooglePlacesInterfacedeletePlace in interface GooglePlacesInterfaceplace - to deleteprotected InputStream download(String uri)
protected InputStream downloadPhoto(Photo photo, int maxWidth, int maxHeight, Param... extraParams)
public List<Prediction> getPlacePredictions(String input, int offset, int lat, int lng, int radius, Param... extraParams)
GooglePlacesInterfacegetPlacePredictions in interface GooglePlacesInterfaceinput - user inputoffset - offset of text caretlat - latitudelng - longituderadius - radiusextraParams - to append to request urlpublic List<Prediction> getPlacePredictions(String input, int offset, Param... extraParams)
GooglePlacesInterfacegetPlacePredictions in interface GooglePlacesInterfaceinput - user inputoffset - offset of text caretpublic List<Prediction> getPlacePredictions(String input, Param... extraParams)
GooglePlacesInterfacegetPlacePredictions in interface GooglePlacesInterfaceinput - user inputextraParams - extra params to include in urlpublic List<Prediction> getQueryPredictions(String input, int offset, int lat, int lng, int radius, Param... extraParams)
GooglePlacesInterfacegetQueryPredictions in interface GooglePlacesInterfaceinput - user inputextraParams - to append to request urlpublic List<Prediction> getQueryPredictions(String input, int offset, Param... extraParams)
GooglePlacesInterfacegetQueryPredictions in interface GooglePlacesInterfaceinput - user inputoffset - offset of text caretextraParams - extra params to append to urlpublic List<Prediction> getQueryPredictions(String input, Param... extraParams)
GooglePlacesInterfacegetQueryPredictions in interface GooglePlacesInterfaceinput - user inputextraParams - extra parameters to append to urlCopyright © 2014–2015. All rights reserved.