Google Place Details android - 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.

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

Display location on Map using voice command -Xamarin Android

how to implement display searched location on Map using Voice Command in Xamarin Android
For this you can use Google places Autocomplete APi's, which will give a result based about on your queried place name, Once you got your place name over Voice command pass that to the places API, And also there are a lot of query params that you can pass with the api to increase the probability of the search place query
For that you use this to kick start Places API, this shows the implementation of the Google places Autocomplete API, And also please follow this discussion about the api
Here is the list of query params and structure
Hope this helps :)

How can i get an image of a city with Google Places API?

It's quite easy in Android and Swift to get an image for famous sights and attractions via Google Places API.
But it is not possible to get an image from a whole city.
For Example:
When using the Google Place id of a sight (e.g. the Brandenburger Gate, with a Place Id of "ChIJiQnyVcZRqEcRY0xnhE77uyY") the Google Places API returns an image.
But when using the Google Place Id of a city (e.g. New York, with a Place Id of "ChIJOwg_06VPwokRYv534QaPC8g") the Google Places Api does not return any image.
Does anybody know if it is posible to get an image from a city? When yes, how can i achieve this using Java (Android)?
UPDATE: This problem does not exist anymore, it looks like google did some changes here. Now The Place API returns images for cities as well.
Firstly find a id for particular place using this url https://developers.google.com/places/place-id
then after getting the id find details for that place using Place details url.
https://developers.google.com/places/web-service/details

Download Specific data from Google maps?

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. :)

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.

Categories

Resources