Download Specific data from Google maps? - android

I am building an Android app which can check in(Something quite like foursquare) to specific places (In this case restaurants),I am just wandering is there a way for me to get data in google maps?(location and name of the place) to my app's database?Adding places manually seems quite impractical as there are lot of places to be added into the database.If it can't what would be the best practical solution?

Actually there is, you can use Google Places API - Nearby Search Requests. From the docs:
Nearby Search Requests
A Nearby Search lets you search for places within a specified area.
You can see an example just below the optional parameters.
The following example is a search request for places of type 'restaurant' within a 500m radius of a point in Sydney, Australia, containing the word 'cruise' in their name:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&type=restaurant&name=cruise&key=YOUR_API_KEY
then to retrieve further details using a Place Details Request, as described in the reference Search Results parameter:
reference contains a unique token that you can use to retrieve additional information about this place in a Place Details request. Although this token uniquely identifies the place, the converse is not true. A place may have many valid reference tokens. It's not guaranteed that the same token will be returned for any given place across different searches.
Note: The reference is now deprecated in favor of place_id.
Hope this helps you in some way. Good luck. :)

Related

Google Places consuming from REST not filtering by desired type

I'm consuming a result from the REST API of Google Places, so far this is what Google Maps tell me about the nearest places around me
Now, I'm using this URL to query my results
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=lat,long&radius=50&type=restaurantkeyword=restaurant&key=MY_API_KEY
According to this, I'm using the correct type = to filter my query.
I'm filtering by type restaurant with a radios of 50 meters; now, the result that the rest provides to me is this:
Where you can see that the results showing here are not for the type restaurant, but instead it searches for all establishments as the FAQ says
Why are some places not returned when I filter by type? It's possible
that the place you are looking for has not yet been categorized. All
places are categorized as the generic type "establishment" until
Google has enough data about a place to categorize it as one of the
supported place types.
As a workaround you can pass the place type to the keyword parameter.
The keyword parameter is matched to: name, type, address, and customer
reviews.
If you would like to add the category type to a place listing
yourself, submit a place edit. Once the edit has been approved and
published it will appear using the correct type filtering.
But the problem is that indeed in Google Maps it appears to be restaurants near me, but the query just return all the establishments around me.
Is there a way to fix that response in order to just return the restaurants near me and not all the places?
Your url query has bug. You need to insert an '&' between restaurant and keyword. I tested with the below query and it looks correct:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-31.41668,-64.1909&radius=50&type=restaurant&keyword=restaurant&key=MY_API_KEY

Google Place Details android

I am working with Google Places API.
My task is to type some name, example Amazon and it should return me the type of this place as Shop.
In short if I pass place name to some web service it should return me the type of that place.
I tried two solutions
1)Place Autocomplete
I don't want to use this, because It returns so many results
2)Google Place Details API
Here I need to pass place ID instead of place name.
So any one knows, How can I get Place details by passing it name to some web service.
Thank you
You have to use the combination of Google Places API and Places Autocomplete API.
Places Autocomplete API will provide AutocompletePrediction from there you can pick up the placeId that you will use with Google Places API to get the details of that place.
I know you said you don't want to use Google Autocomplete API but it can be configured to return a max number of results (default is 10 I think) and can be also configured to return certain types of places by adding AutocompleteFilter. This will limit the results and it will also return useful results for your case.

How to get list of "colleges" based on preferences nearby using google place api?

I have worked with the google place api and hence i know how to work with it to get the basics but how do i get the list of colleges nearby because google place api doesn't have that tag yet, they have school, moreover it doesn't provide me the link that i want to filter.
The filters should be based on the following:
the result should return what type of college is it (either private or govt., engineering or medical)
minimum eligibility criteria
location(this i can get)
the fee
So i want to know is there a way to retrieve all these data from the http request? As i have tried with the field as school and i haven't received the following except location of course or how does college search websites work?
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=lng,lat&radius=5000&types=school&sensor=true&key=........
But google mapdoes give the following result when we google for colleges
You can use the "university" tag if you only want colleges. However, the JSON response does not include information like application fees or what type of college it is (at least not yet):
Each result within the results array may contain the following fields:
icon contains the URL of a recommended icon which may be displayed to the user when indicating this result.
id contains a unique stable identifier denoting this place. This identifier may not be used to retrieve information about this place,
but is guaranteed to be valid across sessions. It can be used to
consolidate data about this place, and to verify the identity of a
place across separate searches. Note: The id is now deprecated in
favor of place_id. See the deprecation notice on this page.
geometry contains geometry information about the result, generally including the location (geocode) of the place and (optionally) the
viewport identifying its general area of coverage.
name contains the human-readable name for the returned result. For establishment results, this is usually the business name.
opening_hours may contain the following information:
open_now is a boolean value indicating if the place is open at the current time.
photos[] — an array of photo objects, each containing a reference to an image. A Place Search will return at most one photo object.
Performing a Place Details request on the place may return up to ten
photos. More information about Place Photos and how you can use the
images in your application can be found in the Place Photos
documentation. A photo object is described as:
photo_reference — a string used to identify the photo when you perform a Photo request.
height — the maximum height of the image.
width — the maximum width of the image.
html_attributions[] — contains any required attributions. This field will always be present, but may be empty.
place_id — a textual identifier that uniquely identifies a place. To retrieve information about the place, pass this identifier in the
placeId field of a Places API request. For more information about
place IDs, see the place ID overview.
scope — Indicates the scope of the place_id. The possible values are:
APP: The place ID is recognised by your application only. This is because your application added the place, and the place has not yet
passed the moderation process.
GOOGLE: The place ID is available to other applications and on Google Maps.
Note: The scope field is included only in Nearby Search results and Place Details results. You can only retrieve app-scoped places via
the Nearby Search and the Place Details requests. If the scope field
is not present in a response, it is safe to assume the scope is
GOOGLE.
alt_ids — An array of zero, one or more alternative place IDs for the place, with a scope related to each alternative ID.
Note: This
array may be empty or not present. If present, it contains the
following fields:
place_id — The most likely reason for a place to have an alternative place ID is if your application adds a place and receives
an application-scoped place ID, then later receives a Google-scoped
place ID after passing the moderation process.
scope — The scope of an alternative place ID will always be APP, indicating that the alternative place ID is recognised by your
application only.

Place present on Google Maps, but not showing in Places API call

I am using Google Places API in my Android app to detect bike shops in the user's proximity. I have a problem with this shop (Joy Ride Bicycles): https://www.google.ro/maps/place/Joy+Ride/#47.03567,-122.818342,17z/data=!3m1!4b1!4m2!3m1!1s0x54910b4572c99c39:0x340b219b8ac15ba1
Although it's present on Google Maps, it isn't returned when I make a call to the Google Nearby Places API. I have tried with different ranges locations. I've had similar issues with other shops.
Has anyone else encountered this problem?
There can be multiple reason according to Google Documentation
Why are some Places not returned when I filter by type?
It's possible that the place you are looking for has not yet been
categorized. All places are categorized as the generic type
"establishment" until Google has enough data about a place to
categorize it as one of the supported place types.
As a workaround you can pass the place type to the keyword parameter.
The keyword parameter is matched to: name, type, address, and customer
reviews.
If you would like to add the category type to a place listing
yourself, submit a place edit. Once the edit has been approved and
published it will appear using the correct type filtering.
Why are some nearby places not returned?
By default, the Places API sorts results by prominence within the
supplied radius. A Nearby Search request can return up to 60 results,
split across three pages. If a Place ranks 22nd in prominence, it will
appear on the second page of results which you can access through
paging. If a Place ranks greater than 60th in prominence it will not
be included in the search result, even if it is closer to the center
of your search.
You can sort your results by distance instead of prominence by setting
the rankby parameter in your query to distance and omitting the radius
parameter. Relevance will be ignored and places will be returned in
order of distance from location.
If you are filtering your request by type, some results may be
filtered out of the response.

Google places API- place type. How can I customize this?

I got this 1 line code from developers.google.com.
Can anyone explain to me what does the code means. and can I replace museum with hospitals under the types part, since im developing an app that navigates to hospitals
" https://maps.googleapis.com/maps/api/place/radarsearch/json?
location=51.503186,-0.126446&radius=5000&types=museum&key=AddYourOwnKeyHere"
Check this. list of supported place types
https://developers.google.com/places/documentation/supported_types
types — Restricts the results to places matching at least one of the specified types. Types should be separated with a pipe symbol (type1|type2|etc)
Check this https://developers.google.com/places/documentation/search
This Code Needs API_KEY to be access this line...
it Contains Following Parts
location=51.503186,-0.126446 - Latitude and Longitude, means a place from where it starts searching
radius=5000 - "radius" localizes results to a certain radius.
types=museum - Restricts the results to places matching at least one of the specified types (You can change it to "hospital")
key=AddYourOwnKeyHere - Your application's API key. This key identifies your application for purposes of quota management and so that places added from your application are made immediately available to your app
Follow This Document For More Info... Place Search

Categories

Resources