First of all, the question is which one should be used?
- Google places Library Or
- Google Places Web service APIs
Below given is some short descriptions on both of these
Google Places Library
The Google Javascript places library enable an application to search for places contained within a defined area such as bounds of a map, or a near by point.
The Places service is a self contained library separate from the main javascript code. To use the functionality contained within this library, one must first load it using the libraries in the maps api bootstrap url. Below is the format to be used to specify as part of the bootstrap url
Below is the format to create a places service and perform search
- Google places Library Or
- Google Places Web service APIs
Below given is some short descriptions on both of these
Google Places Library
The Google Javascript places library enable an application to search for places contained within a defined area such as bounds of a map, or a near by point.
The Places service is a self contained library separate from the main javascript code. To use the functionality contained within this library, one must first load it using the libraries in the maps api bootstrap url. Below is the format to be used to specify as part of the bootstrap url
Below is the format to create a places service and perform search
service = new google.maps.places.PlacesService(map); service.search(request, callback);
Using the request parameter, we can specify
bounds, a location and radiud, keyword ( a search terms which to be matched against all fields including
name, type and address as well as customer reviews), rankBy (specifying whether to be
ordered based on prominence or by distance.OR by types (an array containing one or more
predefined types.
For e.g. if places are to be displayed for the below categories, such as ATM, Gas station,
and hospital, within the bounds of the map, below can be the search
var bounds = gMap.getBounds()
var categories[] = [atm, gas_station, hospital];
service = new google.maps.places.PlacesService(map);
service.search(request,callback);
Places API will give a callback to the callback function passed in to process the response.
Upon receiving the response, we should check the response status and process the
response. Response status are mainly the below ones
ERROR
: There was a problem contacting the Google
servers
INVALID_REQUEST
: This request was invali
OK
: The response contains a valid result.
OVER_QUERY_LIMIT
: The webpage has gone over its request quota.
NOT_FOUND
The referenced location was not found in the Places database.
REQUEST_DENIED
: The webpage is not allowed to use the PlacesService.
UNKNOWN_ERROR
: The PlacesService request could not be processed due to a server error. The request may succeed if you try again.
ZERO_RESULTS
: No result was found for this request.
below is the processing in the callback
function callback(result, status)
{
if(status == google.maps.places.PlacesServiceStatus.OK)
{
var place = result[i];
}
}
No comments:
Post a Comment