Android based on JSON data show multiple markers in google map And HORIZONTAL RecyclerView example


Library

implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'




json.txt



{  
   "restaurants" : [  
      {  
        "name": "Hopdoddy Burger Bar",  
        "backgroundImageURL": "http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/hopdoddy.png",  
        "category" : "Burgers",  
       "contact": {  
         "phone": "9723872337",  
         "formattedPhone": "(972) 387-2337",  
         "twitter": "hopdoddy"  
       },  
       "location": {  
         "address": "5100 Belt Line Road, STE 502",  
         "crossStreet": "Dallas North Tollway",  
         "lat": 32.950787,  
         "lng": -96.821118,  
         "postalCode": "75254",  
         "cc": "US",  
         "city": "Addison",  
         "state": "TX",  
         "country": "United States",  
         "formattedAddress": [  
           "5100 Belt Line Road, STE 502 (Dallas North Tollway)",  
           "Addison, TX 75254",  
           "United States"  
         ]  
       }  
      },  
      {  
        "name": "Pappadeaux Seafood Kitchen",  
        "backgroundImageURL": "http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/pappadeaux.png",  
        "category": "Seafood",  
       "contact": {  
         "phone": "9724479616",  
         "formattedPhone": "(972) 447-9616",  
         "twitter": "pappadeaux"  
       },  
       "location": {  
         "address": "18349 Dallas Pkwy",  
         "crossStreet": "at Frankford Rd.",  
         "lat": 32.99908456526653,  
         "lng": -96.83018780592823,  
         "postalCode": "75287",  
         "cc": "US",  
         "city": "Dallas",  
         "state": "TX",  
         "country": "United States",  
         "formattedAddress": [  
           "18349 Dallas Pkwy (at Frankford Rd.)",  
           "Dallas, TX 75287",  
           "United States"  
         ]  
       }  
      },  
      {  
        "name": "Yard House",  
        "backgroundImageURL": "http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/yardhouse.png",  
        "category": "Tap House",  
       "contact": {  
         "phone": "9727164004",  
         "formattedPhone": "(972) 716-4004",  
         "twitter": "yardhouse",  
         "facebook": "92873089221",  
         "facebookUsername": "YardHouse",  
         "facebookName": "Yard House"  
       },  
       "location": {  
         "address": "5100 Belt Line Rd",  
         "lat": 32.95061646,  
         "lng": -96.81974196,  
         "postalCode": "75254",  
         "cc": "US",  
         "city": "Dallas",  
         "state": "TX",  
         "country": "United States",  
         "formattedAddress": [  
           "5100 Belt Line Rd",  
           "Dallas, TX 75254",  
           "United States"  
         ]  
       }  
      },  
      {  
        "name": "Pluckers Wing Bar",  
        "backgroundImageURL": "http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/pluckers.png",  
        "category": "Wing Joint",  
       "contact": null,  
       "location": {  
         "address": "5100 Beltline Rd",  
         "lat": 32.95097877918451,  
         "lng": -96.82020769859702,  
         "cc": "US",  
         "city": "Addison",  
         "state": "TX",  
         "country": "United States",  
         "formattedAddress": [  
           "5100 Beltline Rd",  
           "Addison, TX",  
           "United States"  
         ]  
       }  
      },  
      {  
        "name": "Ramen Hakata",  
        "backgroundImageURL": "http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/ramen_hakata.png",  
        "category": "Japanese",  
       "contact": {  
         "phone": "9722472401",  
         "formattedPhone": "(972) 247-2401",  
         "twitter": "ramenhakata"  
       },  
       "location": {  
         "address": "3714 Belt Line Rd",  
         "crossStreet": "Marsh",  
         "lat": 32.95270483276971,  
         "lng": -96.85424159312772,  
         "postalCode": "75001",  
         "cc": "US",  
         "city": "Addison",  
         "state": "TX",  
         "country": "United States",  
         "formattedAddress": [  
           "3714 Belt Line Rd (Marsh)",  
           "Addison, TX 75001",  
           "United States"  
         ]  
       }  
      },  
      {  
        "name": "Gloria's",  
        "backgroundImageURL": "http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/glorias.png",  
        "category": "Mexican",  
       "contact": {  
         "phone": "9723878442",  
         "formattedPhone": "(972) 387-8442",  
         "twitter": "gloriasdfw",  
         "facebook": "37663492804",  
         "facebookUsername": "GloriasAddison"  
       },  
       "location": {  
         "address": "5100 Belt Line Rd, #864",  
         "crossStreet": "btwn Dallas Pkwy & Montfort Dr",  
         "lat": 32.95233983087431,  
         "lng": -96.8217200548765,  
         "postalCode": "75254",  
         "cc": "US",  
         "city": "Dallas",  
         "state": "TX",  
         "country": "United States",  
         "formattedAddress": [  
           "5100 Belt Line Rd, #864 (btwn Dallas Pkwy & Montfort Dr)",  
           "Dallas, TX 75254",  
           "United States"  
         ]  
       }  
      },  
      {  
        "name": "The Social House",  
        "backgroundImageURL": "http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/social_house.png",  
        "category": "Bar and Grill",  
       "contact": {  
         "phone": "9723924300",  
         "formattedPhone": "(972) 392-4300"  
       },  
       "location": {  
         "address": "5100 Belt Line Rd, Ste 410",  
         "lat": 32.951435866666664,  
         "lng": -96.81982755661011,  
         "postalCode": "75254",  
         "cc": "US",  
         "city": "Addison",  
         "state": "TX",  
         "country": "United States",  
         "formattedAddress": [  
           "5100 Belt Line Rd, Ste 410",  
           "Addison, TX 75254",  
           "United States"  
         ]  
       }  
      },  
      {  
        "name": "Chuy's",  
        "backgroundImageURL": "http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/chuys.png",  
        "category": "Tex Mex",  
       "contact": null,  
       "location": {  
         "address": "4440 Belt Line Rd",  
         "lat": 32.95374271930925,  
         "lng": -96.83582486129093,  
         "postalCode": "75001",  
         "cc": "US",  
         "city": "Addison",  
         "state": "TX",  
         "country": "United States",  
         "formattedAddress": [  
           "4440 Belt Line Rd",  
           "Addison, TX 75001",  
           "United States"  
         ]  
       }  
      },  
      {  
        "name": "Flying Saucer Draught Emporium",  
        "backgroundImageURL": "http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/flying_saucer.png",  
        "category": "Tap House",  
       "contact": {  
         "phone": "9729917093",  
         "formattedPhone": "(972) 991-7093"  
       },  
       "location": {  
         "address": "14999 Montfort Dr",  
         "crossStreet": "at Sakowitz Dr.",  
         "lat": 32.95293601457525,  
         "lng": -96.81884050369263,  
         "postalCode": "75254",  
         "cc": "US",  
         "city": "Dallas",  
         "state": "TX",  
         "country": "United States",  
         "formattedAddress": [  
           "14999 Montfort Dr (at Sakowitz Dr.)",  
           "Dallas, TX 75254",  
           "United States"  
         ]  
       }  
      },  
      {  
        "name": "Whole Foods Market",  
        "backgroundImageURL": "http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/whole_foods.png",  
        "category": "Prepared Eats",  
       "contact": {  
         "phone": "2148543334",  
         "formattedPhone": "(214) 854-3334",  
         "twitter": "wholefoodsdfw"  
       },  
       "location": {  
         "address": "5100 Belt Line Rd., Suite 1012",  
         "crossStreet": "at Dallas North Twy.",  
         "lat": 32.95285141460555,  
         "lng": -96.8211496464768,  
         "postalCode": "75254",  
         "cc": "US",  
         "city": "Addison",  
         "state": "TX",  
         "country": "United States",  
         "formattedAddress": [  
           "5100 Belt Line Rd., Suite 1012 (at Dallas North Twy.)",  
           "Addison, TX 75254",  
           "United States"  
         ]  
       }  
      },  
      {  
        "name": "The Londoner",  
        "backgroundImageURL": "http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/the_londoner.png",  
        "category": "Pub",  
       "contact": {  
         "phone": "9724582444",  
         "formattedPhone": "(972) 458-2444"  
       },  
       "location": {  
         "address": "14930 Midway Rd",  
         "crossStreet": "at Beltway Dr",  
         "lat": 32.952423,  
         "lng": -96.83843538333333,  
         "postalCode": "75001",  
         "cc": "US",  
         "city": "Addison",  
         "state": "TX",  
         "country": "United States",  
         "formattedAddress": [  
           "14930 Midway Rd (at Beltway Dr)",  
           "Addison, TX 75001",  
           "United States"  
         ]  
       }  
      },  
      {  
        "name": "The Original Pancake House",  
        "backgroundImageURL": "http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/original_pancake_house.png",  
        "category": "Coffee and Breakfast",  
       "contact": {  
         "phone": "9723856468",  
         "formattedPhone": "(972) 385-6468"  
       },  
       "location": {  
         "address": "5220 Belt Line Rd",  
         "crossStreet": "at Dallas North Tollway",  
         "lat": 32.953633,  
         "lng": -96.81984901428223,  
         "postalCode": "75254",  
         "cc": "US",  
         "city": "Dallas",  
         "state": "TX",  
         "country": "United States",  
         "formattedAddress": [  
           "5220 Belt Line Rd (at Dallas North Tollway)",  
           "Dallas, TX 75254",  
           "United States"  
         ]  
       }  
      },  
      {  
        "name": "Thai Star",  
        "backgroundImageURL": "http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/thai_star.png",  
        "category": "Thai",  
       "contact": {  
         "phone": "9729916334",  
         "formattedPhone": "(972) 991-6334"  
       },  
       "location": {  
         "address": "14833 Midway Rd",  
         "crossStreet": "at Beltway Dr",  
         "lat": 32.95027115867483,  
         "lng": -96.8406629562378,  
         "postalCode": "75001",  
         "cc": "US",  
         "city": "Addison",  
         "state": "TX",  
         "country": "United States",  
         "formattedAddress": [  
           "14833 Midway Rd (at Beltway Dr)",  
           "Addison, TX 75001",  
           "United States"  
         ]  
       }  
      },  
      {  
        "name": "In-N-Out Burger",  
        "backgroundImageURL": "http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/in_n_out_burger.png",  
        "category": "Fast Food Burgers",  
       "contact": {  
         "phone": "8007861000",  
         "formattedPhone": "(800) 786-1000",  
         "twitter": "innoutburger"  
       },  
       "location": {  
         "address": "15260 Dallas Pkwy",  
         "crossStreet": "at Prestonwood Town Center",  
         "lat": 32.95703457542545,  
         "lng": -96.82081996316793,  
         "postalCode": "75248",  
         "cc": "US",  
         "city": "Dallas",  
         "state": "TX",  
         "country": "United States",  
         "formattedAddress": [  
           "15260 Dallas Pkwy (at Prestonwood Town Center)",  
           "Dallas, TX 75248",  
           "United States"  
         ]  
       }  
      },  
      {  
        "name": "Buffalo Wild Wings",  
        "backgroundImageURL": "http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/buffalo_wild_wings.png",  
        "category": "Wing Joint",  
       "contact": {  
         "phone": "9727019464",  
         "formattedPhone": "(972) 701-9464",  
         "twitter": "bwwings"  
       },  
       "location": {  
         "address": "5000 Belt Line Rd Ste 100",  
         "crossStreet": "at Quorum Dr",  
         "lat": 32.95347617827522,  
         "lng": -96.82554602622986,  
         "postalCode": "75254-6752",  
         "cc": "US",  
         "city": "Dallas",  
         "state": "TX",  
         "country": "United States",  
         "formattedAddress": [  
           "5000 Belt Line Rd Ste 100 (at Quorum Dr)",  
           "Dallas, TX 75254-6752",  
           "United States"  
         ]  
       }  
      }  
   ]  
 }  






MapsActivity.java


 package hemanth.smartkit.com.Activity;  
 import android.app.Activity;  
 import android.os.Bundle;  
 import android.support.v4.app.FragmentActivity;  
 import android.support.v7.widget.LinearLayoutManager;  
 import android.support.v7.widget.RecyclerView;  
 import android.util.Log;  
 import android.view.LayoutInflater;  
 import android.view.View;  
 import android.view.ViewGroup;  
 import android.widget.ImageView;  
 import android.widget.TextView;  
 import com.android.volley.Request;  
 import com.android.volley.RequestQueue;  
 import com.android.volley.Response;  
 import com.android.volley.VolleyError;  
 import com.android.volley.VolleyLog;  
 import com.android.volley.toolbox.JsonObjectRequest;  
 import com.android.volley.toolbox.Volley;  
 import com.bumptech.glide.Glide;  
 import com.google.android.gms.maps.CameraUpdateFactory;  
 import com.google.android.gms.maps.GoogleMap;  
 import com.google.android.gms.maps.OnMapReadyCallback;  
 import com.google.android.gms.maps.SupportMapFragment;  
 import com.google.android.gms.maps.model.BitmapDescriptorFactory;  
 import com.google.android.gms.maps.model.LatLng;  
 import com.google.android.gms.maps.model.Marker;  
 import com.google.android.gms.maps.model.MarkerOptions;  
 import com.google.gson.Gson;  
 import com.google.gson.reflect.TypeToken;  
 import org.json.JSONArray;  
 import org.json.JSONException;  
 import org.json.JSONObject;  
 import java.lang.reflect.Type;  
 import java.util.List;  
 import hemanth.smartkit.com.Bean.RestaurantBean;  
 import hemanth.smartkit.com.R;  
 public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {  
   private final String TAG = "rlog";  
   private GoogleMap mMap;  
   String url = "http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/restaurants.json";  
   private RequestQueue queue;  
   RecyclerView recyclerView;  
   @Override  
   protected void onCreate(Bundle savedInstanceState) {  
     super.onCreate(savedInstanceState);  
     setContentView(R.layout.activity_maps);  
     // Obtain the SupportMapFragment and get notified when the map is ready to be used.  
     SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()  
         .findFragmentById(R.id.map);  
     mapFragment.getMapAsync(this);  
     recyclerView = findViewById(R.id.recycle);  
     queue = Volley.newRequestQueue(this);  
     getLocationsInformation();  
   }  
   /**  
    * Manipulates the map once available.  
    * This callback is triggered when the map is ready to be used.  
    * This is where we can add markers or lines, add listeners or move the camera. In this case,  
    * we just add a marker near Sydney, Australia.  
    * If Google Play services is not installed on the device, the user will be prompted to install  
    * it inside the SupportMapFragment. This method will only be triggered once the user has  
    * installed Google Play services and returned to the app.  
    */  
   @Override  
   public void onMapReady(GoogleMap googleMap) {  
     mMap = googleMap;  
     // Add a marker in Sydney and move the camera  
     LatLng sydney = new LatLng(32.950787,  -96.821118 );  
 //    mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));  
     mMap.animateCamera( CameraUpdateFactory.newLatLngZoom( sydney , 10f ) );  
 //    mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));  
   }  
   private Marker previousMarker = null;  
   private void getLocationsInformation(){  
     JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET,  
         url,  
         new Response.Listener<JSONObject>() {  
           @Override  
           public void onResponse(JSONObject response) {  
             String res = "{\n" +  
                 "  \"restaurants\" : [\n" +  
                 "\t{\n" +  
                 "\t  \"name\": \"Hopdoddy Burger Bar\",\n" +  
                 "\t  \"backgroundImageURL\": \"http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/hopdoddy.png\",\n" +  
                 "\t  \"category\" : \"Burgers\",\n" +  
                 "      \"contact\": {\n" +  
                 "        \"phone\": \"9723872337\",\n" +  
                 "        \"formattedPhone\": \"(972) 387-2337\",\n" +  
                 "        \"twitter\": \"hopdoddy\"\n" +  
                 "      },\n" +  
                 "      \"location\": {\n" +  
                 "        \"address\": \"5100 Belt Line Road, STE 502\",\n" +  
                 "        \"crossStreet\": \"Dallas North Tollway\",\n" +  
                 "        \"lat\": 32.950787,\n" +  
                 "        \"lng\": -96.821118,\n" +  
                 "        \"postalCode\": \"75254\",\n" +  
                 "        \"cc\": \"US\",\n" +  
                 "        \"city\": \"Addison\",\n" +  
                 "        \"state\": \"TX\",\n" +  
                 "        \"country\": \"United States\",\n" +  
                 "        \"formattedAddress\": [\n" +  
                 "          \"5100 Belt Line Road, STE 502 (Dallas North Tollway)\",\n" +  
                 "          \"Addison, TX 75254\",\n" +  
                 "          \"United States\"\n" +  
                 "        ]\n" +  
                 "      }\n" +  
                 "\t},\n" +  
                 "\t{\n" +  
                 "\t  \"name\": \"Pappadeaux Seafood Kitchen\",\n" +  
                 "\t  \"backgroundImageURL\": \"http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/pappadeaux.png\",\n" +  
                 "\t  \"category\": \"Seafood\",\n" +  
                 "      \"contact\": {\n" +  
                 "        \"phone\": \"9724479616\",\n" +  
                 "        \"formattedPhone\": \"(972) 447-9616\",\n" +  
                 "        \"twitter\": \"pappadeaux\"\n" +  
                 "      },\n" +  
                 "      \"location\": {\n" +  
                 "        \"address\": \"18349 Dallas Pkwy\",\n" +  
                 "        \"crossStreet\": \"at Frankford Rd.\",\n" +  
                 "        \"lat\": 32.99908456526653,\n" +  
                 "        \"lng\": -96.83018780592823,\n" +  
                 "        \"postalCode\": \"75287\",\n" +  
                 "        \"cc\": \"US\",\n" +  
                 "        \"city\": \"Dallas\",\n" +  
                 "        \"state\": \"TX\",\n" +  
                 "        \"country\": \"United States\",\n" +  
                 "        \"formattedAddress\": [\n" +  
                 "          \"18349 Dallas Pkwy (at Frankford Rd.)\",\n" +  
                 "          \"Dallas, TX 75287\",\n" +  
                 "          \"United States\"\n" +  
                 "        ]\n" +  
                 "      }\n" +  
                 "\t},\n" +  
                 "\t{\n" +  
                 "\t  \"name\": \"Yard House\",\n" +  
                 "\t  \"backgroundImageURL\": \"http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/yardhouse.png\",\n" +  
                 "\t  \"category\": \"Tap House\",\n" +  
                 "      \"contact\": {\n" +  
                 "        \"phone\": \"9727164004\",\n" +  
                 "        \"formattedPhone\": \"(972) 716-4004\",\n" +  
                 "        \"twitter\": \"yardhouse\",\n" +  
                 "        \"facebook\": \"92873089221\",\n" +  
                 "        \"facebookUsername\": \"YardHouse\",\n" +  
                 "        \"facebookName\": \"Yard House\"\n" +  
                 "      },\n" +  
                 "      \"location\": {\n" +  
                 "        \"address\": \"5100 Belt Line Rd\",\n" +  
                 "        \"lat\": 32.95061646,\n" +  
                 "        \"lng\": -96.81974196,\n" +  
                 "        \"postalCode\": \"75254\",\n" +  
                 "        \"cc\": \"US\",\n" +  
                 "        \"city\": \"Dallas\",\n" +  
                 "        \"state\": \"TX\",\n" +  
                 "        \"country\": \"United States\",\n" +  
                 "        \"formattedAddress\": [\n" +  
                 "          \"5100 Belt Line Rd\",\n" +  
                 "          \"Dallas, TX 75254\",\n" +  
                 "          \"United States\"\n" +  
                 "        ]\n" +  
                 "      }\n" +  
                 "\t},\n" +  
                 "\t{\n" +  
                 "\t  \"name\": \"Pluckers Wing Bar\",\n" +  
                 "\t  \"backgroundImageURL\": \"http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/pluckers.png\",\n" +  
                 "\t  \"category\": \"Wing Joint\",\n" +  
                 "      \"contact\": null,\n" +  
                 "      \"location\": {\n" +  
                 "        \"address\": \"5100 Beltline Rd\",\n" +  
                 "        \"lat\": 32.95097877918451,\n" +  
                 "        \"lng\": -96.82020769859702,\n" +  
                 "        \"cc\": \"US\",\n" +  
                 "        \"city\": \"Addison\",\n" +  
                 "        \"state\": \"TX\",\n" +  
                 "        \"country\": \"United States\",\n" +  
                 "        \"formattedAddress\": [\n" +  
                 "          \"5100 Beltline Rd\",\n" +  
                 "          \"Addison, TX\",\n" +  
                 "          \"United States\"\n" +  
                 "        ]\n" +  
                 "      }\n" +  
                 "\t},\n" +  
                 "\t{\n" +  
                 "\t  \"name\": \"Ramen Hakata\",\n" +  
                 "\t  \"backgroundImageURL\": \"http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/ramen_hakata.png\",\n" +  
                 "\t  \"category\": \"Japanese\",\n" +  
                 "      \"contact\": {\n" +  
                 "        \"phone\": \"9722472401\",\n" +  
                 "        \"formattedPhone\": \"(972) 247-2401\",\n" +  
                 "        \"twitter\": \"ramenhakata\"\n" +  
                 "      },\n" +  
                 "      \"location\": {\n" +  
                 "        \"address\": \"3714 Belt Line Rd\",\n" +  
                 "        \"crossStreet\": \"Marsh\",\n" +  
                 "        \"lat\": 32.95270483276971,\n" +  
                 "        \"lng\": -96.85424159312772,\n" +  
                 "        \"postalCode\": \"75001\",\n" +  
                 "        \"cc\": \"US\",\n" +  
                 "        \"city\": \"Addison\",\n" +  
                 "        \"state\": \"TX\",\n" +  
                 "        \"country\": \"United States\",\n" +  
                 "        \"formattedAddress\": [\n" +  
                 "          \"3714 Belt Line Rd (Marsh)\",\n" +  
                 "          \"Addison, TX 75001\",\n" +  
                 "          \"United States\"\n" +  
                 "        ]\n" +  
                 "      }\n" +  
                 "\t},\n" +  
                 "\t{\n" +  
                 "\t  \"name\": \"Gloria's\",\n" +  
                 "\t  \"backgroundImageURL\": \"http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/glorias.png\",\n" +  
                 "\t  \"category\": \"Mexican\",\n" +  
                 "      \"contact\": {\n" +  
                 "        \"phone\": \"9723878442\",\n" +  
                 "        \"formattedPhone\": \"(972) 387-8442\",\n" +  
                 "        \"twitter\": \"gloriasdfw\",\n" +  
                 "        \"facebook\": \"37663492804\",\n" +  
                 "        \"facebookUsername\": \"GloriasAddison\"\n" +  
                 "      },\n" +  
                 "      \"location\": {\n" +  
                 "        \"address\": \"5100 Belt Line Rd, #864\",\n" +  
                 "        \"crossStreet\": \"btwn Dallas Pkwy & Montfort Dr\",\n" +  
                 "        \"lat\": 32.95233983087431,\n" +  
                 "        \"lng\": -96.8217200548765,\n" +  
                 "        \"postalCode\": \"75254\",\n" +  
                 "        \"cc\": \"US\",\n" +  
                 "        \"city\": \"Dallas\",\n" +  
                 "        \"state\": \"TX\",\n" +  
                 "        \"country\": \"United States\",\n" +  
                 "        \"formattedAddress\": [\n" +  
                 "          \"5100 Belt Line Rd, #864 (btwn Dallas Pkwy & Montfort Dr)\",\n" +  
                 "          \"Dallas, TX 75254\",\n" +  
                 "          \"United States\"\n" +  
                 "        ]\n" +  
                 "      }\n" +  
                 "\t},\n" +  
                 "\t{\n" +  
                 "\t  \"name\": \"The Social House\",\n" +  
                 "\t  \"backgroundImageURL\": \"http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/social_house.png\",\n" +  
                 "\t  \"category\": \"Bar and Grill\",\n" +  
                 "      \"contact\": {\n" +  
                 "        \"phone\": \"9723924300\",\n" +  
                 "        \"formattedPhone\": \"(972) 392-4300\"\n" +  
                 "      },\n" +  
                 "      \"location\": {\n" +  
                 "        \"address\": \"5100 Belt Line Rd, Ste 410\",\n" +  
                 "        \"lat\": 32.951435866666664,\n" +  
                 "        \"lng\": -96.81982755661011,\n" +  
                 "        \"postalCode\": \"75254\",\n" +  
                 "        \"cc\": \"US\",\n" +  
                 "        \"city\": \"Addison\",\n" +  
                 "        \"state\": \"TX\",\n" +  
                 "        \"country\": \"United States\",\n" +  
                 "        \"formattedAddress\": [\n" +  
                 "          \"5100 Belt Line Rd, Ste 410\",\n" +  
                 "          \"Addison, TX 75254\",\n" +  
                 "          \"United States\"\n" +  
                 "        ]\n" +  
                 "      }\n" +  
                 "\t},\n" +  
                 "\t{\n" +  
                 "\t  \"name\": \"Chuy's\",\n" +  
                 "\t  \"backgroundImageURL\": \"http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/chuys.png\",\n" +  
                 "\t  \"category\": \"Tex Mex\",\n" +  
                 "      \"contact\": null,\n" +  
                 "      \"location\": {\n" +  
                 "        \"address\": \"4440 Belt Line Rd\",\n" +  
                 "        \"lat\": 32.95374271930925,\n" +  
                 "        \"lng\": -96.83582486129093,\n" +  
                 "        \"postalCode\": \"75001\",\n" +  
                 "        \"cc\": \"US\",\n" +  
                 "        \"city\": \"Addison\",\n" +  
                 "        \"state\": \"TX\",\n" +  
                 "        \"country\": \"United States\",\n" +  
                 "        \"formattedAddress\": [\n" +  
                 "          \"4440 Belt Line Rd\",\n" +  
                 "          \"Addison, TX 75001\",\n" +  
                 "          \"United States\"\n" +  
                 "        ]\n" +  
                 "      }\n" +  
                 "\t},\n" +  
                 "\t{\n" +  
                 "\t  \"name\": \"Flying Saucer Draught Emporium\",\n" +  
                 "\t  \"backgroundImageURL\": \"http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/flying_saucer.png\",\n" +  
                 "\t  \"category\": \"Tap House\",\n" +  
                 "      \"contact\": {\n" +  
                 "        \"phone\": \"9729917093\",\n" +  
                 "        \"formattedPhone\": \"(972) 991-7093\"\n" +  
                 "      },\n" +  
                 "      \"location\": {\n" +  
                 "        \"address\": \"14999 Montfort Dr\",\n" +  
                 "        \"crossStreet\": \"at Sakowitz Dr.\",\n" +  
                 "        \"lat\": 32.95293601457525,\n" +  
                 "        \"lng\": -96.81884050369263,\n" +  
                 "        \"postalCode\": \"75254\",\n" +  
                 "        \"cc\": \"US\",\n" +  
                 "        \"city\": \"Dallas\",\n" +  
                 "        \"state\": \"TX\",\n" +  
                 "        \"country\": \"United States\",\n" +  
                 "        \"formattedAddress\": [\n" +  
                 "          \"14999 Montfort Dr (at Sakowitz Dr.)\",\n" +  
                 "          \"Dallas, TX 75254\",\n" +  
                 "          \"United States\"\n" +  
                 "        ]\n" +  
                 "      }\n" +  
                 "\t},\n" +  
                 "\t{\n" +  
                 "\t  \"name\": \"Whole Foods Market\",\n" +  
                 "\t  \"backgroundImageURL\": \"http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/whole_foods.png\",\n" +  
                 "\t  \"category\": \"Prepared Eats\",\n" +  
                 "      \"contact\": {\n" +  
                 "        \"phone\": \"2148543334\",\n" +  
                 "        \"formattedPhone\": \"(214) 854-3334\",\n" +  
                 "        \"twitter\": \"wholefoodsdfw\"\n" +  
                 "      },\n" +  
                 "      \"location\": {\n" +  
                 "        \"address\": \"5100 Belt Line Rd., Suite 1012\",\n" +  
                 "        \"crossStreet\": \"at Dallas North Twy.\",\n" +  
                 "        \"lat\": 32.95285141460555,\n" +  
                 "        \"lng\": -96.8211496464768,\n" +  
                 "        \"postalCode\": \"75254\",\n" +  
                 "        \"cc\": \"US\",\n" +  
                 "        \"city\": \"Addison\",\n" +  
                 "        \"state\": \"TX\",\n" +  
                 "        \"country\": \"United States\",\n" +  
                 "        \"formattedAddress\": [\n" +  
                 "          \"5100 Belt Line Rd., Suite 1012 (at Dallas North Twy.)\",\n" +  
                 "          \"Addison, TX 75254\",\n" +  
                 "          \"United States\"\n" +  
                 "        ]\n" +  
                 "      }\n" +  
                 "\t},\n" +  
                 "\t{\n" +  
                 "\t  \"name\": \"The Londoner\",\n" +  
                 "\t  \"backgroundImageURL\": \"http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/the_londoner.png\",\n" +  
                 "\t  \"category\": \"Pub\",\n" +  
                 "      \"contact\": {\n" +  
                 "        \"phone\": \"9724582444\",\n" +  
                 "        \"formattedPhone\": \"(972) 458-2444\"\n" +  
                 "      },\n" +  
                 "      \"location\": {\n" +  
                 "        \"address\": \"14930 Midway Rd\",\n" +  
                 "        \"crossStreet\": \"at Beltway Dr\",\n" +  
                 "        \"lat\": 32.952423,\n" +  
                 "        \"lng\": -96.83843538333333,\n" +  
                 "        \"postalCode\": \"75001\",\n" +  
                 "        \"cc\": \"US\",\n" +  
                 "        \"city\": \"Addison\",\n" +  
                 "        \"state\": \"TX\",\n" +  
                 "        \"country\": \"United States\",\n" +  
                 "        \"formattedAddress\": [\n" +  
                 "          \"14930 Midway Rd (at Beltway Dr)\",\n" +  
                 "          \"Addison, TX 75001\",\n" +  
                 "          \"United States\"\n" +  
                 "        ]\n" +  
                 "      }\n" +  
                 "\t},\n" +  
                 "\t{\n" +  
                 "\t  \"name\": \"The Original Pancake House\",\n" +  
                 "\t  \"backgroundImageURL\": \"http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/original_pancake_house.png\",\n" +  
                 "\t  \"category\": \"Coffee and Breakfast\",\n" +  
                 "      \"contact\": {\n" +  
                 "        \"phone\": \"9723856468\",\n" +  
                 "        \"formattedPhone\": \"(972) 385-6468\"\n" +  
                 "      },\n" +  
                 "      \"location\": {\n" +  
                 "        \"address\": \"5220 Belt Line Rd\",\n" +  
                 "        \"crossStreet\": \"at Dallas North Tollway\",\n" +  
                 "        \"lat\": 32.953633,\n" +  
                 "        \"lng\": -96.81984901428223,\n" +  
                 "        \"postalCode\": \"75254\",\n" +  
                 "        \"cc\": \"US\",\n" +  
                 "        \"city\": \"Dallas\",\n" +  
                 "        \"state\": \"TX\",\n" +  
                 "        \"country\": \"United States\",\n" +  
                 "        \"formattedAddress\": [\n" +  
                 "          \"5220 Belt Line Rd (at Dallas North Tollway)\",\n" +  
                 "          \"Dallas, TX 75254\",\n" +  
                 "          \"United States\"\n" +  
                 "        ]\n" +  
                 "      }\n" +  
                 "\t},\n" +  
                 "\t{\n" +  
                 "\t  \"name\": \"Thai Star\",\n" +  
                 "\t  \"backgroundImageURL\": \"http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/thai_star.png\",\n" +  
                 "\t  \"category\": \"Thai\",\n" +  
                 "      \"contact\": {\n" +  
                 "        \"phone\": \"9729916334\",\n" +  
                 "        \"formattedPhone\": \"(972) 991-6334\"\n" +  
                 "      },\n" +  
                 "      \"location\": {\n" +  
                 "        \"address\": \"14833 Midway Rd\",\n" +  
                 "        \"crossStreet\": \"at Beltway Dr\",\n" +  
                 "        \"lat\": 32.95027115867483,\n" +  
                 "        \"lng\": -96.8406629562378,\n" +  
                 "        \"postalCode\": \"75001\",\n" +  
                 "        \"cc\": \"US\",\n" +  
                 "        \"city\": \"Addison\",\n" +  
                 "        \"state\": \"TX\",\n" +  
                 "        \"country\": \"United States\",\n" +  
                 "        \"formattedAddress\": [\n" +  
                 "          \"14833 Midway Rd (at Beltway Dr)\",\n" +  
                 "          \"Addison, TX 75001\",\n" +  
                 "          \"United States\"\n" +  
                 "        ]\n" +  
                 "      }\n" +  
                 "\t},\n" +  
                 "\t{\n" +  
                 "\t  \"name\": \"In-N-Out Burger\",\n" +  
                 "\t  \"backgroundImageURL\": \"http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/in_n_out_burger.png\",\n" +  
                 "\t  \"category\": \"Fast Food Burgers\",\n" +  
                 "      \"contact\": {\n" +  
                 "        \"phone\": \"8007861000\",\n" +  
                 "        \"formattedPhone\": \"(800) 786-1000\",\n" +  
                 "        \"twitter\": \"innoutburger\"\n" +  
                 "      },\n" +  
                 "      \"location\": {\n" +  
                 "        \"address\": \"15260 Dallas Pkwy\",\n" +  
                 "        \"crossStreet\": \"at Prestonwood Town Center\",\n" +  
                 "        \"lat\": 32.95703457542545,\n" +  
                 "        \"lng\": -96.82081996316793,\n" +  
                 "        \"postalCode\": \"75248\",\n" +  
                 "        \"cc\": \"US\",\n" +  
                 "        \"city\": \"Dallas\",\n" +  
                 "        \"state\": \"TX\",\n" +  
                 "        \"country\": \"United States\",\n" +  
                 "        \"formattedAddress\": [\n" +  
                 "          \"15260 Dallas Pkwy (at Prestonwood Town Center)\",\n" +  
                 "          \"Dallas, TX 75248\",\n" +  
                 "          \"United States\"\n" +  
                 "        ]\n" +  
                 "      }\n" +  
                 "\t},\n" +  
                 "\t{\n" +  
                 "\t  \"name\": \"Buffalo Wild Wings\",\n" +  
                 "\t  \"backgroundImageURL\": \"http://sandbox.bottlerocketapps.com/BR_iOS_CodingExam_2015_Server/Images/buffalo_wild_wings.png\",\n" +  
                 "\t  \"category\": \"Wing Joint\",\n" +  
                 "      \"contact\": {\n" +  
                 "        \"phone\": \"9727019464\",\n" +  
                 "        \"formattedPhone\": \"(972) 701-9464\",\n" +  
                 "        \"twitter\": \"bwwings\"\n" +  
                 "      },\n" +  
                 "      \"location\": {\n" +  
                 "        \"address\": \"5000 Belt Line Rd Ste 100\",\n" +  
                 "        \"crossStreet\": \"at Quorum Dr\",\n" +  
                 "        \"lat\": 32.95347617827522,\n" +  
                 "        \"lng\": -96.82554602622986,\n" +  
                 "        \"postalCode\": \"75254-6752\",\n" +  
                 "        \"cc\": \"US\",\n" +  
                 "        \"city\": \"Dallas\",\n" +  
                 "        \"state\": \"TX\",\n" +  
                 "        \"country\": \"United States\",\n" +  
                 "        \"formattedAddress\": [\n" +  
                 "          \"5000 Belt Line Rd Ste 100 (at Quorum Dr)\",\n" +  
                 "          \"Dallas, TX 75254-6752\",\n" +  
                 "          \"United States\"\n" +  
                 "        ]\n" +  
                 "      }\n" +  
                 "\t}\n" +  
                 "  ]\n" +  
                 "}";  
             if(response != null){  
               try {  
                 JSONArray jsonArr = response.getJSONArray("restaurants");  
                 Type listType = new TypeToken<List<RestaurantBean>>() {}.getType();  
                 List<RestaurantBean> restaurantsList = new Gson().fromJson(jsonArr.toString(), listType);  
                 recyclerView.setLayoutManager(new LinearLayoutManager(MapsActivity.this , LinearLayoutManager.HORIZONTAL, false ));  
                 recyclerView.setAdapter(new RestaurantAdapter(MapsActivity.this , restaurantsList));  
                 Log.d(TAG, restaurantsList.size() + "");  
                 for(int i = 0 ; i < restaurantsList.size() ; i++) {  
                   createMarker(restaurantsList.get(i));  
                 }  
               } catch (JSONException e) {  
                 e.printStackTrace();  
               }  
             }  
           }  
         }, new Response.ErrorListener() {  
       @Override  
       public void onErrorResponse(VolleyError error) {  
         VolleyLog.d(TAG, "Error: " + error.getMessage());  
         // hide the progress dialog  
       }  
     });  
     queue.add(jsonObjReq);  
   }  
   private Marker createMarker(RestaurantBean restaurant){  
     return mMap.addMarker(new MarkerOptions()  
         .position(new LatLng(restaurant.location.getLat(), restaurant.getLocation().getLng()))  
         .anchor(0.5f, 0.5f)  
         .title(restaurant.getName())  
         .snippet("res")  
         .icon(BitmapDescriptorFactory.fromResource(R.drawable.icons)));  
   }  
   class RestaurantAdapter extends RecyclerView.Adapter<RestaurantAdapter.ViewHolder>{  
     Activity activity ;  
     List<RestaurantBean> list;  
     public RestaurantAdapter(Activity activity, List<RestaurantBean> list) {  
       this.activity = activity;  
       this.list = list;  
     }  
     @Override  
     public RestaurantAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {  
       return new ViewHolder(LayoutInflater.from(activity).inflate(R.layout.recycle_item_layout , parent , false));  
     }  
     @Override  
     public void onBindViewHolder(RestaurantAdapter.ViewHolder holder, int position) {  
       Glide.with(activity)  
           .load(list.get(position).backgroundImageURL)  
           .into(holder.img);  
       holder.tv_title.setText(list.get(position).getName());  
       holder.tv_address.setText(list.get(position).getLocation().getAddress() + " , "+ list.get(position).getLocation().getCrossStreet() +" ," + list.get(position).getLocation().getCity() + " , "+ list.get(position).getLocation().getCountry());  
     }  
     @Override  
     public int getItemCount() {  
       return list.size();  
     }  
     public class ViewHolder extends RecyclerView.ViewHolder {  
       ImageView img;  
       TextView tv_title , tv_address;  
       public ViewHolder(View itemView) {  
         super(itemView);  
         img = itemView.findViewById(R.id.img_pic);  
         tv_title = itemView.findViewById(R.id.restaurant_name);  
         tv_address = itemView.findViewById(R.id.tv_address);  
       }  
     }  
   }  
 } 


RestaurantBean.java

 package hemanth.smartkit.com.Bean;  
 import android.os.Parcel;  
 import android.os.Parcelable;  
 public class RestaurantBean implements Parcelable {  
 String name;  
 public String backgroundImageURL;  
 String category;  
 public RestaurantLoactionBean location;  
   protected RestaurantBean(Parcel in) {  
     name = in.readString();  
     backgroundImageURL = in.readString();  
     category = in.readString();  
   }  
   public static final Creator<RestaurantBean> CREATOR = new Creator<RestaurantBean>() {  
     @Override  
     public RestaurantBean createFromParcel(Parcel in) {  
       return new RestaurantBean(in);  
     }  
     @Override  
     public RestaurantBean[] newArray(int size) {  
       return new RestaurantBean[size];  
     }  
   };  
   public String getName() {  
     return name;  
   }  
   public void setName(String name) {  
     this.name = name;  
   }  
   public String getBackgroundImageURL() {  
     return backgroundImageURL;  
   }  
   public void setBackgroundImageURL(String backgroundImageURL) {  
     this.backgroundImageURL = backgroundImageURL;  
   }  
   public String getCategory() {  
     return category;  
   }  
   public void setCategory(String category) {  
     this.category = category;  
   }  
   public RestaurantLoactionBean getLocation() {  
     return location;  
   }  
   public void setLocation(RestaurantLoactionBean location) {  
     this.location = location;  
   }  
   @Override  
   public int describeContents() {  
     return 0;  
   }  
   @Override  
   public void writeToParcel(Parcel parcel, int i) {  
     parcel.writeString(name);  
     parcel.writeString(backgroundImageURL);  
     parcel.writeString(category);  
   }  
 }  


RestaurantLoactionBean.java

package hemanth.smartkit.com.Bean;  
 public class RestaurantLoactionBean {  
   String address;  
   String crossStreet;  
   double lat;  
   double lng;  
   String city;  
   String state;  
   String country;  
   public String getAddress() {  
     return address;  
   }  
   public void setAddress(String address) {  
     this.address = address;  
   }  
   public String getCrossStreet() {  
     return crossStreet;  
   }  
   public void setCrossStreet(String crossStreet) {  
     this.crossStreet = crossStreet;  
   }  
   public double getLat() {  
     return lat;  
   }  
   public void setLat(double lat) {  
     this.lat = lat;  
   }  
   public double getLng() {  
     return lng;  
   }  
   public void setLng(double lng) {  
     this.lng = lng;  
   }  
   public String getCity() {  
     return city;  
   }  
   public void setCity(String city) {  
     this.city = city;  
   }  
   public String getState() {  
     return state;  
   }  
   public void setState(String state) {  
     this.state = state;  
   }  
   public String getCountry() {  
     return country;  
   }  
   public void setCountry(String country) {  
     this.country = country;  
   }  
 }  



activity_maps.xml

<?xml version="1.0" encoding="utf-8"?>  
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
   xmlns:map="http://schemas.android.com/apk/res-auto"  
   xmlns:tools="http://schemas.android.com/tools"  
   android:layout_width="match_parent"  
   android:focusableInTouchMode="true"  
   android:layout_height="match_parent">  
   <fragment  
     android:id="@+id/map"  
     android:name="com.google.android.gms.maps.SupportMapFragment"  
     android:layout_width="match_parent"  
     android:layout_height="match_parent"  
     tools:context=".MapsActivity" />  
   <android.support.v7.widget.RecyclerView  
     android:layout_width="wrap_content"  
     android:layout_height="wrap_content"  
     android:id="@+id/recycle"  
     android:layout_alignParentBottom="true"/>  
 </RelativeLayout>  



recycle_item_layout.xml

 <?xml version="1.0" encoding="utf-8"?>  
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
   android:layout_width="300dp"  
   android:layout_height="wrap_content"  
   android:background="#ffffff"  
   android:layout_margin="5dp">  
   <ImageView  
     android:layout_width="300dp"  
     android:layout_height="150dp"  
     android:id="@+id/img_pic"  
     android:scaleType="centerCrop"  
     android:src="@drawable/icons"/>  
   <LinearLayout  
     android:layout_width="match_parent"  
     android:layout_height="wrap_content"  
     android:orientation="vertical"  
     android:layout_below="@+id/img_pic"  
     android:layout_margin="10dp">  
   <TextView  
     android:layout_width="wrap_content"  
     android:layout_height="wrap_content"  
     android:layout_alignParentRight="true"  
     android:text="TITLE"  
     android:id="@+id/restaurant_name"  
     android:textColor="#222222"  
     android:textStyle="bold"  
    />  
     <TextView  
       android:layout_width="wrap_content"  
       android:layout_height="wrap_content"  
       android:text="address"  
       android:layout_marginTop="10dp"  
       android:id="@+id/tv_address"/>  
   </LinearLayout>  
 </RelativeLayout>