Anand Jain
Anand Jain

Reputation: 2385

Restrict user in google place api in 5 Km area given location lat lng

I want to set google place auto complete text box, but I want the user only to see those places listed, which are in under 5 Km by set location. I don't talk about near-by search. I tried google map API, but it does not show correctly. I used this API.

Upvotes: 6

Views: 1505

Answers (3)

Nandhu
Nandhu

Reputation: 158

You can use LatLng Bounds to Restrict Places usage

There is a workaround to do this , but involves a little bittle computation

Current Location + Distance in North Direction = new LatLngBounds;

currentLocation + south Direction (possibly you have to convert km to radians) = new SouthBounds;

and Add Bounds to widget

myPlaceAutoComplete.setBounds(northBounds,southBounds)

Upvotes: 0

fmello
fmello

Reputation: 563

Your issue is probably because your radius is 500. Try changing it to 5000.

The places autocomplete webservice documentation says the radius should be in meters.

tl;dr

Try this link

Upvotes: 0

Related Questions