Reputation: 678
I'm trying to make an app that finds the users location and then searches for for example nearby restaurants. I have a method to find the users location the only thing that is left is to find the restaurants nearby the user. How can I do this? Plz Help!
Upvotes: 3
Views: 5987
Reputation: 11756
I don't know about any native android soultions but you can make a Get request to this Google Places API webservice
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=8.5586,76.8814&radius=500&types=food&sensor=false&key=[Your_KEY]
And parse the Json to get the restaurants nearby
location - Latitude,Longitude of the place
radius - Required radius to search your request
key - Your API Key
types - Types of places to search
Get an Api key and create a sample request in the browser, You will get a big json result something like this
Goto websites like this which can generate POJO classes for your Json the best configuration is given below:
Download files and extract it and add them to your source code,You will get some errors at first because you may not have the annotation libraries in your build.gradle
Add these lines in your app's build.gradle
:
dependencies{
compile 'com.google.code.gson:gson:2.3.1'
compile 'javax.annotation:javax.annotation-api:1.2-b01'
}
YourGooglePlacesClass object=new Gson().fromJson(jsonString,YourGooglePlacesClass.class)
Upvotes: 4
Reputation: 2998
You can check out the PlacePicker API that's native uses the Google Places API for Android. For samples, Google provided it in their googlesamples github repo, you can check those out!
Upvotes: 3