How to get Places Reference Key? - google-places-api

I have few lat,lng of some Google Places business which I want to search and get detailed information about that place.
I was looking at Place Detail search which require reference key of particular place page.
Here is what I am doing is.
Do Place search via api key for lat,lng
https://maps.googleapis.com/maps/api/place/nearbysearch/xml?location=lat,lng&radius=50&location=lat,lng&name=placenamesensor=false&key=my key
that returns exact place page result in xml and i grab ref key of that page.
then do call
https://maps.googleapis.com/maps/api/place/details/xml?reference=RefKey&sensor=false&key=MyKey
which gives output of particular business.
Now question is on 1st step to get ref key of business what if I dont know name but just know lat,lng and wish to grab ref key of that page. What query I have to fire to reduce api calls limit?

You can find it here:
I believe this is what you are looking for
https://developers.google.com/maps/documentation/javascript/places
you need to work with places api and implement the the typeahead feature
https://developers.google.com/maps/documentation/javascript/places#TextSearchRequests

Related

Find Place requests Returns Only One Result

I'm using the Google Places API endpoint "findplacefromtext" and tried a search similar to the example.
https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=mongolian%20grill&inputtype=textquery&fields=photos,formatted_address,name,opening_hours,rating&locationbias=circle:2000#47.6918452,-122.2226413&key=YOUR_API_KEY
However, when you use this it only ever returns one result. There is a cafe near me that's called "Cream" but when you pass that as the "input" parameter it returns shops that have a category of "Ice Cream". I thought it should only search the name of the business.... If I can't find the place by name does it search the category type as a fall back? When I execute the same search in Google Maps it returns the same data but I get multiple results and I can see the place I am trying to retrieve 3rd on the search result list.
Is it possible to make it return more than one result? The documentation doesn't mention anything about this.
I believe what you need is the Text Search request. The Find Place request is meant for exact addresses.
The Google Places API Text Search Service is a web service that
returns information about a set of places based on a string — for
example "pizza in New York" or "shoe stores near Ottawa" or "123 Main
Street". The service responds with a list of places matching the text
string and any location bias that has been set.
The service is especially useful for making ambiguous address queries
in an automated system, and non-address components of the string may
match businesses as well as addresses. Examples of ambiguous address
queries are incomplete addresses, poorly formatted addresses, or a
request that includes non-address components such as business names.
Taken from https://developers.google.com/maps/documentation/places/web-service/search#TextSearchRequests

performance testing on google maps

Our client has implemented google maps on which user can select particular location from the map which can be added by the user and perform the next action of it. How should i test the dynamic value appearing from the google maps for a particular search criteria ..
for example here is the scenario
you search a location--> get the desired result go to google map--> click on the add button of that location and proceed futhur.
How should i design my testplan/scripts for the same.
I cannot go for correlation also because the value of data is not define in the previous sample using regular expression.I want to change the data dynamically in the same sampler.
Thanks :) :) :)

Google Place Autocomplete API not returning latest city name

I'm making use of google's Place Autocomplete API to get list of cities,
https://developers.google.com/places/web-service/autocomplete.
Problem is when I search "Bombay", it should return the new city name
"Mumbai". Same for "Calcutta" instead "Kolkata" and "Madras" to "Chennai".
Google Place Search api returns all the right renamed city names but unfortunately it's not for autocomplete use.
In Text search API you will get new names :
https://maps.googleapis.com/maps/api/place/autocomplete/json?key=YOUR_KEY&types=city&query=Bombay
So If you can use above API you can use.
In autocomplete add types=(cities) but it returning old names only, I think google data is not updated.
https://maps.googleapis.com/maps/api/place/autocomplete/json?key=YOUR_KEY&types=(cities)&input=Bombay
I think the fool proof solution for this is to use Google place autocomplete and get a list of predictions. Then use the first prediction's place_id as an input for Google Place details
Step 1
Step 2

Returning custom contact fields via the Google contacts api

I have been unable to return any UserDefined/custom fields for a contact. I'm not even wanting to create or update an existing entry as per Programatically adding "New Custom Field" To Google Contacts using Google contact API
I have followed the guide here https://developers.google.com/google-apps/contacts/v3/reference, but still to no avail.
I've called both
https://www.google.com/m8/feeds/contacts/default/full?alt=json
and
https://www.google.com/m8/feeds/contacts/default/full/DEADBEEF?alt=json
in an attempt to get ALL of the values returned. I thought I might have to call each contact id specifically to get the full details, but that doesn't work either.
DEADBEEF is clearly replaced with a valid contact id in my scenario.
/contacts/default determines that request should return contacts for the current auth'd user, which is myself in this case.
Has anyone managed to return custom values, is this even possible?
Thanks
I found the answer, add the ?v=3.0 to the url string eg
https://www.google.com/m8/feeds/contacts/default/full/DEADBEEF?alt=json&v=3.0
However, you should use the preferred method of adding a GData-Version header.

Can I obtain the country name with Google Places API?

On the request for current place I receive a list of places. Every place has an address but that address is a string so I can't get only the country name.
Could someone help me on this matter?
Country is only explicitly available when using the Place Details API, not the Places API. (https://developers.google.com/maps/documentation/places/web-service/details)
You first need to look up a place_id for the specific place you're looking for. You then use your place_id to pull details from the Details API, which includes information like:
Fully formatted address, including country
Address components
Sample reviews
Phone # and website
Operating hours
If you have read the Google Places Autocomplete doc,you must know about API properties.you can use the type as '(region)' and will return you many results (plus country).And if you look inside address_components field (it's array with dynamic length),you will see,that the last item of array is what you need.Here is a great page to read a correct doc and try examples yourself.
http://www.w3docs.com/learn-javascript/places-autocomplete.html

Resources