Google Maps Nearby Places API using Retrofit Android

Skip links

Main navigation

Google Maps Nearby Places API

Hello Guys. Hope all of you are doing well. In this tutorial, we will learn how to add the markers on nearby places in Google Maps API using . We will name this App as Google Maps Nearby Places API. You can see demo of this tutorial in above video. This is one of the most crystal clear tutorials where minimum code is used to implement nearby places app using retrofit. We made a similar tutorial on

but that was implemented using Async Task. Now Async task has become pretty much mediocre and people are using Retrofit to capture data from URL, So we made this tutorial on similar lines. Now you don’t have to make any JSON Parser or Data capture class. Retrofit Android automatically takes care of it. All the people who do not know how to use Retrofit Android can see our tutorial of .

1) Android Studio installed on your PC (Unix or Windows). You can learn how to install it .

2) A real time android device (Smartphone or Tablet) .

3) A basic knowledge of

& functions used in Android Studio.

Before going through this post we will suggest you to first have a look at our post on . That information (inside link) will be used in this post.

Now let’s make it. We hope you would have already made an . So we are not repeating that part now. Also if you don’t want to learn Retrofit then you can refer our tutorial of

where we have used Async Task to implement exactly same tutorial.

Please follow following steps:

Open Android Studio and make a new project with name “Google Maps Retrofit” or “Google Maps Nearby Places API” and company domain (I used my company domain i.e Similarly you can use yours).

Click Next and choose android version Lollipop. Again Click Next and Choose Google Maps Activity

(as shown in following pic).

Leave all things remaining same and Click Finish.

Now you will be able to see three files:

google_maps_api.xml (…/GoogleMapsSearchNearby/app/src/debug/res/values/google_maps_api.xml) (…/GoogleMapsSearchNearby/app/src/main/java/com/androidtutorialpoint/googlemapssearchnearby


AndroidManifest.xml ( …/GoogleMapsSearchNearby/app/src/main/AndroidManifest.xml)

Open google_maps_api.xml. Here you will find a lot of information along with a link. Copy-Paste this link in your web browser. Make a Gmail account through which you will configure google play services.

Now at the browser choose “Create New Project” and Click Continue. Following screen will be displayed:

Click on Go to credentials. Below screen will appear.

Create your key by clicking Create. Now a key will be created but there is one big change here as compared to our previous Google Maps tutorials. Here you will need a Server Key. So to generate a Server Key click on Create Credentials and then API Key as shown in the following image:

Click on Server Key. Below screen will appear:

Click Create and copy the Server Key generated. You shall copy and paste this key in google_maps_api.xml. Copy paste it in place where YOUR_KEY_HERE is written:

Code inside google_maps_api.xml is complete.



If you go inside AndroidManifest.xml then this key will be displayed in meta tags. Here you need to add permissions for accessing location of device. The required permission should be as follows:

ACCESS_NETWORK_STATE – To check network state i.e if we are connected to any network or not.

INTERNET – If we are connected to Internet or not.

ACCESS_COARSE_LOCATION – To determine user’s location using WiFi and mobile. It will give us an approximate location.

ACCESS_FINE_LOCATION – To determine user’s location using GPS. It will give us precise location.

OpenGL ES V2 – Required for Google Maps V2


Here we will add three buttons each for Restaurant, Hospitals and Schools such that when user clicks on Restaurant then markers will be added on nearby restaurants. Similarly in case of other two buttons. For this, we will use . Refer below code:


Read More Post