Home > Software design >  Google Maps Find Place API locationbias causing zero results
Google Maps Find Place API locationbias causing zero results

Time:10-20

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 Dunes 1 Unit 308 Seascape Resort&inputtype=textquery&locationbias=rectangle:30.119056,-86.527098|30.444872,-85.705723&fields=geometry/location,name,place_id

Response:

{ "candidates" : [], "status" : "ZERO_RESULTS"}

Without locationbias: https://maps.googleapis.com/maps/api/place/findplacefromtext/json?inputtype=textquery&fields=geometry/location,name,place_id&input=Ariel Dunes 1 Unit 308 Seascape Resort

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.

CodePudding user response:

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