I am trying to use the locationbias feature of the Find Place API to provide more relevant results for my searches. I have tried both a point and a rectangle, and in both cases my query returns zero results. However, if I remove the bias completely I do get a result. Why is a location that I know is within the boundary of the rectangle not being returned? Also, the field is called locationbias implying it will prefer Places near this location but not force strict boundaries, so why am I getting zero results?
Here is an example GET: https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=Ariel%20Dunes%201%20Unit%20308%20Seascape%20Resort&inputtype=textquery&locationbias=rectangle%3A30.119056%2C-86.527098%7C30.444872%2C-85.705723&fields=geometry%2Flocation%2Cname%2Cplace_id
Response:
{ "candidates" : [], "status" : "ZERO_RESULTS"}
Without locationbias: https://maps.googleapis.com/maps/api/place/findplacefromtext/json?inputtype=textquery&fields=geometry%2Flocation%2Cname%2Cplace_id&input=Ariel%20Dunes%201%20Unit%20308%20Seascape%20Resort
Response:
{ "candidates" : [ { "geometry" : { "location" : { "lat" : 30.377608, "lng" : -86.366795 } }, "name" : "Ariel Dunes I (ADI) at Seascape Resort", "place_id" : "ChIJF5B7IoRbkYgRQWjAZv0-wUI" } ], "status" : "OK" }
For clarity, here's the decoded locationbias used above: rectangle:30.119056,-86.527098|30.444872,-85.705723
According to the docs this should be the southwest corner of the rectangle followed by the northeast corner of the rectangle.
The issue was due to my use of Postman. Postman implicitly encodes the query string. Disabling this feature allowed me to use a literal colon between the shape and the coordinates which corrected the behavior.
Related
I'm looking to find gas stations around based on the location I provided. And it seems that the query string that I provide to the Google API is not really correct, leading to the desired result.
Here is the URL
https://maps.googleapis.com/maps/api/place/nearbysearch/json
And this is my query string:
?location=40.316828,%20-82.839840&radius=50000&type=gas_station&keyword=cruise&key=My_Google_Key
Response returned current>:
{
"html_attributions" : [],
"results" : [],
"status" : "ZERO_RESULTS"
}
The solution is simple, just remove the "keyword" parameter then everything will be ok. If this param is declared, the API will only return results with the same value as the param
Here is my original URL:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=40.316828,%20-82.839840&radius=50000&type=gas_station&keyword=cruise&key=My_Google_Key
Replace with this URL:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=40.316828,%20-82.839840&radius=50000&type=gas_station&key=My_Google_Key
Sorry if this question ends up being obvious to some. Suppose I have manually created a map on Google Maps: I have added a few markers at specific coordinates, each one has a description associated. Now, is there an endpoint in the Google Maps API that lets me execute a query to retrieve data about all the markers? Maybe something that would return a list of markers like
{
...,
"markers" : [
{
"name" : "London",
"lat" : 12.34,
"lng" : 56.78
},
{
"name" : "Paris",
"lat" : 98.76,
"lng" : 54.32
}
]
}
I am aware that those are not the real coordinates of London and Paris :) Thanks!
Answer: there is no way to do this.
you could get some information with a reverse geocode lookup
What type of information are you looking to get?
I recommend taking a look at the api documentation
I'm not getting search results while using the Google api for places. There are also no ratings coming like a week ago. Im getting results for far off places and not nearby. Has Google changing the api or should I wait a little more for Google to give a good places api.
Thanks
I experienced the same issue. Google changed the Places API in late June 2014 to deprecate the reference and id fields in favor of a single place_id. They also changed the detail level in the JSON response. For instance, not including the name parameter in your call like this...
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&types=food&key=YOURKEY
...returns results that look like this:
"html_attributions" : [],
"next_page_token" : "CoQC8gAAALD7H9pFpjSrFHDEn0_rzBef77uvO3hAvsO9u344Jh05RIsiVtkMvAbgZaYbp15lus4mOIbrWtbk-SIJ9j2B5ankZiTt9ZvJBUwOhjkBsCopBR_EhQQO4ZZciVQGFYVl-Zu4Y7vHSx6mKFzZ5rNeqVdFbBOfTeptNIjjs3re9EEkmqa_gFZ60J7DTw0Qgig_Vekq9I0aMF62Y3a3ZvAb4ElFpapxkvkHRRW_r6fYLR7L77JHzxheL_BVuNqDhM8F_lZl9gwe9g5vehb_xkwSOnIl001Ybdntipuyf_dmCpBg_58Vv0Xm0Z8MvNqLSeaE6B5vZXspYxZWqtHCN5andLUSEMgSnJKHtPzxTDkmZcmgulIaFFSiA6dQUakJXIEQCkulMheOBV2t",
"results" : [
{
"geometry" : {
"location" : {
"lat" : -33.871194,
"lng" : 151.19891
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
"id" : "6237ce126ba1afabd5985b059d3d1eca6e9ee0da",
"name" : "Blue Fish",
"place_id" : "ChIJBaqDDzquEmsRcCI5e-3rStM",
"reference" : "CnRsAAAAibazLaEzCLq4fMIASFHDGG81Ls_hY5ycFP-GRfZP5dKRuLblqe8qrzf5BOKVZOtbRwNQ2PN34sQv5o0H_kL_LEZhKPFmpMz7qkAj6a262KGICKoxTznqRILF2bVZVk7SED0qRnpiyo_A304g30itnhIQBmp1tv7ZoYnOGnrqhtTXzhoU2HDzURqpVMfmpAYoEqbVDJg8J9s",
"scope" : "GOOGLE",
"types" : [ "restaurant", "food", "establishment" ],
"vicinity" : "Harbourside Shopping Centre/287 Darling Drive, Sydney CBD"
}
Whereas if you include the name parameter, like this...
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&types=food&name=cruise&key=YOURKEY
...your results return a more detailed response:
"html_attributions" : [],
"results" : [
{
"geometry" : {
"location" : {
"lat" : -33.870775,
"lng" : 151.199025
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/travel_agent-71.png",
"id" : "21a0b251c9b8392186142c798263e289fe45b4aa",
"name" : "Rhythmboat Cruises",
"opening_hours" : {
"open_now" : false
},
"photos" : [
{
"height" : 270,
"html_attributions" : [],
"photo_reference" : "CnRnAAAAOCqDF9u4_e5cEPJq0J3M-37u9fa4IfMJK7-SceKf98mkZAnSbVLPUN-PoHBeW8_32daeNBA-H9dI3xuIERAyBAXfmXB0MbO26ITj0ryvJgHe6V6m2GhxJXFVpv_XSMBp8XsghrHXhfWFidj8p4WCtBIQetaqvTH1oI28Nsd-iHXqFxoU8m00lJGS1J6FJMfQl-kqZjXbf8s",
"width" : 519
}
]
As you can see, the more detailed response provides rating, opening hours, photos, etc., but also requires use of a more detailed URL string.
My app used to pull one set of restaurant data, then pass the information anywhere I needed it (from a TableViewController to a DetailView for example). With this new change, the only band-aid solution we can devise is to make two separate calls to the API. One to retrieve the basic upper layer of information from the JSON object for my TableViewController, the second (after tapping on the cell to create the new URL string, including the name parameter) to fetch the additional more detailed information like rating and opening hours. As you can imagine, this solution will increase the number of API calls tenfold as your users would essentially make an API call every time they reviewed the details of a place. No bueno.
As a result, we're researching other place indexes, such as the built-in Apple MKLocalSearch, which returns a similar, but not identical set of information as Google Places API. Maybe MKLocalSearch will suit your needs.
If others have found a better solution to this change, I think we'd all be open to it.
EDIT
It looks like they want us to use the place_id returned by the text search or nearby search to make another call to get place details. See here.
I am using the Google Maps Directions API v3 to get routes and show them on a mobile app. The code works fine, but suddently I found that sometimes fails. I ended up seeing that the same api call returns different LAT and LON values on refresh or recall.
For instance, the results of this query:
http://maps.googleapis.com/maps/api/directions/json?origin=41.158212,1.104743&destination=41.081765,1.131603®ion=es&sensor=false
Sometimes gives me the coordinate values as
"end_address" : "Carrer de Barcelona, 61-63, 43840 Salou, Tarragona, España",
"end_location" : {
"lat" : 41.08180,
"lng" : 1.131470
},
and on refresh sometimes gives me this:
"end_address" : "Carrer de Barcelona, 61-63, 43840 Salou, Tarragona, España",
"end_location" : {
"lat" : 4108.179590000001,
"lng" : 113.147030
},
My errors come from getting the values as 4108 instead of 41.08. I can workaround this in my code but would like to know if anyone can help me out to find the root cause and try to ensure I always get the proper json answer.
Thanks!
I have an android application that was working great but 2 days ago things started failing. After debugging for a bit, I noticed that I was not able to retrieve details on places that I have added to Places API. After doing a places search based on my location, I do see that my added locations are listed. When I take the reference token provided and attempt to do a Places Details request, I get the following JSON back.
{
"html_attributions" : [],
"status" : "NOT_FOUND"
}
Interestingly, if I use the ORIGINAL token provided to do the same Details request, I do in fact get the details back as such..
{
"html_attributions" : [],
"result" : {
"geometry" : {
"location" : {
"lat" : 44.2778780,
"lng" : -88.39451800000002
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png",
"id" : "c52c0ee9bdd0aea66419a0dfeaed32925f18216e",
"name" : "Amc broom closet",
"reference" : "CmRgAAAAGZwx9penijotKZ9lizruTGr8KPbrTc4CD39tPQZ5rpsoEC0ofXDr
2wpP0Ws9Vr1IIwGtTzRNyOYxOxMKQluhU-_SDydaPKJOsT9F2zqN8gBNPH-
8Lenq4tkfLKdRmhF4EhD5KdxkNndh0J_cdy4lNPI
MGhS8l2EdBcalDXfYRbkiFvWa3Bb8Og",
"types" : [ "other" ]
},
"status" : "OK"
}
If I then take that reference token and try to get Details however, I am once again left with ...
{
"html_attributions" : [],
"status" : "NOT_FOUND"
}
I am quite certain this is a new change.. Maybe I did not test thoroughly enough to begin with (quite possible). It leaves me in a huge quandry however. Because according to the documentation, my original token that works presently, might not work in the future! I'm not sure how to program around that.
Please tell me this is a temporary blip in the system, otherwise, my paddle just washed downstream.
This appears to be a bug, please post it here so we can look into this ASAP.