Get results from nearby locations from a user's location using the Google Maps API on Android

This is the first time that the google maps API and google places API are used. I am making a demo application that displays a list of hospitals (for example) that are closest to the user's location, with routes to each of the hospitals. I managed to get the location of the user with the code below:

public class MainActivity extends ActionBarActivity { private GoogleMap map; UiSettings mapSettings; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); if (map != null) { // map.addMarker(new MarkerOptions().position(myLocation).title("Start")); map.setMyLocationEnabled(true); mapSettings = map.getUiSettings(); mapSettings.setScrollGesturesEnabled(true); mapSettings.setZoomControlsEnabled(true); } } } 

Xml file:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"> <fragment android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.MapFragment" /> </RelativeLayout> 

My question is: how to get a list of hospitals using google places API and display them. Any help, advice, walkthrough or tutorials will really be considered. Thanks at Advance.

+5
source share
3 answers

For Android, I tried using Place picker for Android . It can add a built-in place picker UI widget to your application so that users can select from a set of neighboring places displayed on the map. It is easy to use, you just need to do the following:

 int PLACE_PICKER_REQUEST = 1; PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder(); startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST); 

It will show the interface below to select a place for you, and you can get information about the place using below:

 protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == PLACE_PICKER_REQUEST) { if (resultCode == RESULT_OK) { Place place = PlacePicker.getPlace(data, this); String toastMsg = String.format("Place: %s", place.getName()); Toast.makeText(this, toastMsg, Toast.LENGTH_LONG).show(); } } } 

enter image description here

For more information see the manual here and the code here .

However, it cannot set the type of place because it does not have a function to build in the user interface. If you really need to install, you should use the Google Places API Web Service API here , find the location yourself, analyze the JSON data and show on your own interface.

A neighborhood search allows you to search for places within a specific area. You can refine your search query by providing keywords or by specifying the type of place you are looking for.

A neighboring search request is an HTTP URL of the following form:

 https://maps.googleapis.com/maps/api/place/nearbysearch/output?parameters 

Please note that in the parameters you need to set types=hospital

EDIT

An example of how to submit a search request for specific places in JSON using the google web api API web service API.

Request

 location: -33.8670,151.1957 radius: 500 types: food name: cruise key: API_KEY 

URL for this:

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670,151.1957&radius=500&types=food&name=cruise&key=API_KEY

and Response JSON:

 { "debug_log" : { "line" : [] }, "html_attributions" : [], "logging_info" : { "experiment_id" : [], "query_geographic_location" : "AU" }, "results" : [ { "geometry" : { "location" : { "lat" : -33.86879, "lng" : 151.194217 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png", "id" : "21a0b251c9b8392186142c798263e289fe45b4aa", "name" : "Rhythmboat Cruises", "opening_hours" : { "open_now" : false, "weekday_text" : [] }, "photos" : [ { "height" : 426, "html_attributions" : [ "\u003ca href=\"https://www.google.com/maps/views/profile/104066891898402903288\"\u003eRhythmboat Cruises\u003c/a\u003e" ], "photo_reference" : "CmRdAAAA-YL_I_Gk02blOX6S0nKHry8PFu9pDyp3Y9AnqISsa3Eq8mkbdD5mXuu1Fax60s0nSy3iiX-h5j-ztyLHcc1-782MsLQsgLLa4t3ZgDmCMll-a8ABapZGnZwDKByk67LFEhBgedv_u_eYFsEo9ay8jxJjGhTUHKPJ4G82vBJqSNliuv7UlAtclw", "width" : 640 } ], "place_id" : "ChIJyWEHuEmuEmsRm9hTkapTCrk", "reference" : "CnRmAAAAvQlMKw-XtxEY4vWFCvudF7CEMQGI5ycNbfVgGl9rAF75fdiPOiLJw1k9NL2v8ZIJsOJuRS3Lm9Dw1vga4ajycAs7PlxN1MVnnYT9la0pBvEvSQNlyvszKANS1R4P7Mvk_jhqswMggqCUtwJ13LN2hRIQOiAkLTWUi3DOjVVOw7J5IRoUb_cJyJaJNqKdmkDM2f0OjQjh9F0", "scope" : "GOOGLE", "types" : [ "restaurant", "food", "point_of_interest", "establishment" ], "vicinity" : "Pyrmont Bay Wharf (Near Australia Maritime Museum), Pyrmont, NSW 2009" }, { "geometry" : { "location" : { "lat" : -33.867591, "lng" : 151.201196 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png", "id" : "a97f9fb468bcd26b68a23072a55af82d4b325e0d", "name" : "Australian Cruise Group", "opening_hours" : { "open_now" : false, "weekday_text" : [] }, "photos" : [ { "height" : 1331, "html_attributions" : [ "\u003ca href=\"https://www.google.com/maps/views/profile/110751364053842618118\"\u003eAustralian Cruise Group\u003c/a\u003e" ], "photo_reference" : "CmRdAAAAtEoj29FJcNBccrsu6bHt0xgwVGhYlciCY1fe6gTr_d5_KkeP3LITnOwnpNRJWnX39B04-aIBOKXKJH6ltx948T5vWIYBoah1yZDXsWngWZ5kMsK7xyCB5P_q_xBIBxxUEhAYWeB4PiOm_Jy093fB-j0iGhSYmIs9xB2aa6u-RH8V8lZEk-Q5ig", "width" : 2000 } ], "place_id" : "ChIJrTLr-GyuEmsRBfy61i59si0", "reference" : "CnRqAAAAFbukrZvRNsc05TreHUCrPEya5NcN9v0fFLLaK-D1fSyxFTuQlUDhDstU3qwXKw_fADX4W6guUkexax1nufgiYIuGCKoZPEnup1r-LhGGNz9dn1uf9Of5iOtZ1XgCeDjJaYvGbSB3C0pAXL8r9kOsmhIQbx2Sia2DAWTjtSZwuh5aehoUhM6upqBCDLhGruZAGGsCOwAiIq8", "scope" : "GOOGLE", "types" : [ "restaurant", "travel_agency", "food", "point_of_interest", "establishment" ], "vicinity" : "32 The Promenade, King Street Wharf 5, Sydney" }, { "geometry" : { "location" : { "lat" : -33.870943, "lng" : 151.190311 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/bar-71.png", "id" : "e644f7f34cf875b9919c6548f1b721947362850a", "name" : "Lunch Cruise with Jazz on Sydney Harbour", "opening_hours" : { "open_now" : false, "weekday_text" : [] }, "photos" : [ { "height" : 292, "html_attributions" : [ "\u003ca href=\"https://www.google.com/maps/views/profile/105423912060796272053\"\u003eFrom a Google User\u003c/a\u003e" ], "photo_reference" : "CmRdAAAAR4bqFTKYWdBwZwdBdON_JRD7V_joTwwIPwRUpZIZWkSSd8GQ3P2O-_aQbUJdL2RhoAyzCUIF0f--DI4oXFneTpj5zZfFq-iFiT7i_x0tjnDveIY8tJv-6o0uWSSjYqabEhCKqQWZqrKAoddjDcc64N48GhQZ2T1_ntPzNKCooHpZzlYQ7AxFOA", "width" : 438 } ], "place_id" : "ChIJLfySpTOuEmsRPCRKrzl8ZEY", "reference" : "CoQBewAAAFd2fO_YWGTiT4RzXWb5tsOuOt7YyV_ScQOwm0tqJSrAyACCczeOzV-P_mgZLro1oKP_34Nt0nVC_1OEKAQUcd7cUm7xmAMSX-EkbSWiD0kOWGgGgKuDRtb0t_8qsxBGU_izugWCyK7SRWezTxELYNdkS0OEiSWPnvhxvXuQktBBEhAAtEe7fagW2kUR14T1QpVsGhQBO7YpIyYSPvo4zUJuL_bX30nJZw", "scope" : "GOOGLE", "types" : [ "bar", "restaurant", "food", "point_of_interest", "establishment" ], "vicinity" : "37 Bank St, Pyrmont" } ], "status" : "OK" } -h5j-ztyLHcc1-782MsLQsgLLa4t3ZgDmCMll-a8ABapZGnZwDKByk67LFEhBgedv_u_eYFsEo9ay8jxJjGhTUHKPJ4G82vBJqSNliuv7UlAtclw", { "debug_log" : { "line" : [] }, "html_attributions" : [], "logging_info" : { "experiment_id" : [], "query_geographic_location" : "AU" }, "results" : [ { "geometry" : { "location" : { "lat" : -33.86879, "lng" : 151.194217 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png", "id" : "21a0b251c9b8392186142c798263e289fe45b4aa", "name" : "Rhythmboat Cruises", "opening_hours" : { "open_now" : false, "weekday_text" : [] }, "photos" : [ { "height" : 426, "html_attributions" : [ "\u003ca href=\"https://www.google.com/maps/views/profile/104066891898402903288\"\u003eRhythmboat Cruises\u003c/a\u003e" ], "photo_reference" : "CmRdAAAA-YL_I_Gk02blOX6S0nKHry8PFu9pDyp3Y9AnqISsa3Eq8mkbdD5mXuu1Fax60s0nSy3iiX-h5j-ztyLHcc1-782MsLQsgLLa4t3ZgDmCMll-a8ABapZGnZwDKByk67LFEhBgedv_u_eYFsEo9ay8jxJjGhTUHKPJ4G82vBJqSNliuv7UlAtclw", "width" : 640 } ], "place_id" : "ChIJyWEHuEmuEmsRm9hTkapTCrk", "reference" : "CnRmAAAAvQlMKw-XtxEY4vWFCvudF7CEMQGI5ycNbfVgGl9rAF75fdiPOiLJw1k9NL2v8ZIJsOJuRS3Lm9Dw1vga4ajycAs7PlxN1MVnnYT9la0pBvEvSQNlyvszKANS1R4P7Mvk_jhqswMggqCUtwJ13LN2hRIQOiAkLTWUi3DOjVVOw7J5IRoUb_cJyJaJNqKdmkDM2f0OjQjh9F0", "scope" : "GOOGLE", "types" : [ "restaurant", "food", "point_of_interest", "establishment" ], "vicinity" : "Pyrmont Bay Wharf (Near Australia Maritime Museum), Pyrmont, NSW 2009" }, { "geometry" : { "location" : { "lat" : -33.867591, "lng" : 151.201196 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png", "id" : "a97f9fb468bcd26b68a23072a55af82d4b325e0d", "name" : "Australian Cruise Group", "opening_hours" : { "open_now" : false, "weekday_text" : [] }, "photos" : [ { "height" : 1331, "html_attributions" : [ "\u003ca href=\"https://www.google.com/maps/views/profile/110751364053842618118\"\u003eAustralian Cruise Group\u003c/a\u003e" ], "photo_reference" : "CmRdAAAAtEoj29FJcNBccrsu6bHt0xgwVGhYlciCY1fe6gTr_d5_KkeP3LITnOwnpNRJWnX39B04-aIBOKXKJH6ltx948T5vWIYBoah1yZDXsWngWZ5kMsK7xyCB5P_q_xBIBxxUEhAYWeB4PiOm_Jy093fB-j0iGhSYmIs9xB2aa6u-RH8V8lZEk-Q5ig", "width" : 2000 } ], "place_id" : "ChIJrTLr-GyuEmsRBfy61i59si0", "reference" : "CnRqAAAAFbukrZvRNsc05TreHUCrPEya5NcN9v0fFLLaK-D1fSyxFTuQlUDhDstU3qwXKw_fADX4W6guUkexax1nufgiYIuGCKoZPEnup1r-LhGGNz9dn1uf9Of5iOtZ1XgCeDjJaYvGbSB3C0pAXL8r9kOsmhIQbx2Sia2DAWTjtSZwuh5aehoUhM6upqBCDLhGruZAGGsCOwAiIq8", "scope" : "GOOGLE", "types" : [ "restaurant", "travel_agency", "food", "point_of_interest", "establishment" ], "vicinity" : "32 The Promenade, King Street Wharf 5, Sydney" }, { "geometry" : { "location" : { "lat" : -33.870943, "lng" : 151.190311 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/bar-71.png", "id" : "e644f7f34cf875b9919c6548f1b721947362850a", "name" : "Lunch Cruise with Jazz on Sydney Harbour", "opening_hours" : { "open_now" : false, "weekday_text" : [] }, "photos" : [ { "height" : 292, "html_attributions" : [ "\u003ca href=\"https://www.google.com/maps/views/profile/105423912060796272053\"\u003eFrom a Google User\u003c/a\u003e" ], "photo_reference" : "CmRdAAAAR4bqFTKYWdBwZwdBdON_JRD7V_joTwwIPwRUpZIZWkSSd8GQ3P2O-_aQbUJdL2RhoAyzCUIF0f--DI4oXFneTpj5zZfFq-iFiT7i_x0tjnDveIY8tJv-6o0uWSSjYqabEhCKqQWZqrKAoddjDcc64N48GhQZ2T1_ntPzNKCooHpZzlYQ7AxFOA", "width" : 438 } ], "place_id" : "ChIJLfySpTOuEmsRPCRKrzl8ZEY", "reference" : "CoQBewAAAFd2fO_YWGTiT4RzXWb5tsOuOt7YyV_ScQOwm0tqJSrAyACCczeOzV-P_mgZLro1oKP_34Nt0nVC_1OEKAQUcd7cUm7xmAMSX-EkbSWiD0kOWGgGgKuDRtb0t_8qsxBGU_izugWCyK7SRWezTxELYNdkS0OEiSWPnvhxvXuQktBBEhAAtEe7fagW2kUR14T1QpVsGhQBO7YpIyYSPvo4zUJuL_bX30nJZw", "scope" : "GOOGLE", "types" : [ "bar", "restaurant", "food", "point_of_interest", "establishment" ], "vicinity" : "37 Bank St, Pyrmont" } ], "status" : "OK" } ", { "debug_log" : { "line" : [] }, "html_attributions" : [], "logging_info" : { "experiment_id" : [], "query_geographic_location" : "AU" }, "results" : [ { "geometry" : { "location" : { "lat" : -33.86879, "lng" : 151.194217 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png", "id" : "21a0b251c9b8392186142c798263e289fe45b4aa", "name" : "Rhythmboat Cruises", "opening_hours" : { "open_now" : false, "weekday_text" : [] }, "photos" : [ { "height" : 426, "html_attributions" : [ "\u003ca href=\"https://www.google.com/maps/views/profile/104066891898402903288\"\u003eRhythmboat Cruises\u003c/a\u003e" ], "photo_reference" : "CmRdAAAA-YL_I_Gk02blOX6S0nKHry8PFu9pDyp3Y9AnqISsa3Eq8mkbdD5mXuu1Fax60s0nSy3iiX-h5j-ztyLHcc1-782MsLQsgLLa4t3ZgDmCMll-a8ABapZGnZwDKByk67LFEhBgedv_u_eYFsEo9ay8jxJjGhTUHKPJ4G82vBJqSNliuv7UlAtclw", "width" : 640 } ], "place_id" : "ChIJyWEHuEmuEmsRm9hTkapTCrk", "reference" : "CnRmAAAAvQlMKw-XtxEY4vWFCvudF7CEMQGI5ycNbfVgGl9rAF75fdiPOiLJw1k9NL2v8ZIJsOJuRS3Lm9Dw1vga4ajycAs7PlxN1MVnnYT9la0pBvEvSQNlyvszKANS1R4P7Mvk_jhqswMggqCUtwJ13LN2hRIQOiAkLTWUi3DOjVVOw7J5IRoUb_cJyJaJNqKdmkDM2f0OjQjh9F0", "scope" : "GOOGLE", "types" : [ "restaurant", "food", "point_of_interest", "establishment" ], "vicinity" : "Pyrmont Bay Wharf (Near Australia Maritime Museum), Pyrmont, NSW 2009" }, { "geometry" : { "location" : { "lat" : -33.867591, "lng" : 151.201196 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png", "id" : "a97f9fb468bcd26b68a23072a55af82d4b325e0d", "name" : "Australian Cruise Group", "opening_hours" : { "open_now" : false, "weekday_text" : [] }, "photos" : [ { "height" : 1331, "html_attributions" : [ "\u003ca href=\"https://www.google.com/maps/views/profile/110751364053842618118\"\u003eAustralian Cruise Group\u003c/a\u003e" ], "photo_reference" : "CmRdAAAAtEoj29FJcNBccrsu6bHt0xgwVGhYlciCY1fe6gTr_d5_KkeP3LITnOwnpNRJWnX39B04-aIBOKXKJH6ltx948T5vWIYBoah1yZDXsWngWZ5kMsK7xyCB5P_q_xBIBxxUEhAYWeB4PiOm_Jy093fB-j0iGhSYmIs9xB2aa6u-RH8V8lZEk-Q5ig", "width" : 2000 } ], "place_id" : "ChIJrTLr-GyuEmsRBfy61i59si0", "reference" : "CnRqAAAAFbukrZvRNsc05TreHUCrPEya5NcN9v0fFLLaK-D1fSyxFTuQlUDhDstU3qwXKw_fADX4W6guUkexax1nufgiYIuGCKoZPEnup1r-LhGGNz9dn1uf9Of5iOtZ1XgCeDjJaYvGbSB3C0pAXL8r9kOsmhIQbx2Sia2DAWTjtSZwuh5aehoUhM6upqBCDLhGruZAGGsCOwAiIq8", "scope" : "GOOGLE", "types" : [ "restaurant", "travel_agency", "food", "point_of_interest", "establishment" ], "vicinity" : "32 The Promenade, King Street Wharf 5, Sydney" }, { "geometry" : { "location" : { "lat" : -33.870943, "lng" : 151.190311 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/bar-71.png", "id" : "e644f7f34cf875b9919c6548f1b721947362850a", "name" : "Lunch Cruise with Jazz on Sydney Harbour", "opening_hours" : { "open_now" : false, "weekday_text" : [] }, "photos" : [ { "height" : 292, "html_attributions" : [ "\u003ca href=\"https://www.google.com/maps/views/profile/105423912060796272053\"\u003eFrom a Google User\u003c/a\u003e" ], "photo_reference" : "CmRdAAAAR4bqFTKYWdBwZwdBdON_JRD7V_joTwwIPwRUpZIZWkSSd8GQ3P2O-_aQbUJdL2RhoAyzCUIF0f--DI4oXFneTpj5zZfFq-iFiT7i_x0tjnDveIY8tJv-6o0uWSSjYqabEhCKqQWZqrKAoddjDcc64N48GhQZ2T1_ntPzNKCooHpZzlYQ7AxFOA", "width" : 438 } ], "place_id" : "ChIJLfySpTOuEmsRPCRKrzl8ZEY", "reference" : "CoQBewAAAFd2fO_YWGTiT4RzXWb5tsOuOt7YyV_ScQOwm0tqJSrAyACCczeOzV-P_mgZLro1oKP_34Nt0nVC_1OEKAQUcd7cUm7xmAMSX-EkbSWiD0kOWGgGgKuDRtb0t_8qsxBGU_izugWCyK7SRWezTxELYNdkS0OEiSWPnvhxvXuQktBBEhAAtEe7fagW2kUR14T1QpVsGhQBO7YpIyYSPvo4zUJuL_bX30nJZw", "scope" : "GOOGLE", "types" : [ "bar", "restaurant", "food", "point_of_interest", "establishment" ], "vicinity" : "37 Bank St, Pyrmont" } ], "status" : "OK" } -j0iGhSYmIs9xB2aa6u-RH8V8lZEk-Q5ig", { "debug_log" : { "line" : [] }, "html_attributions" : [], "logging_info" : { "experiment_id" : [], "query_geographic_location" : "AU" }, "results" : [ { "geometry" : { "location" : { "lat" : -33.86879, "lng" : 151.194217 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png", "id" : "21a0b251c9b8392186142c798263e289fe45b4aa", "name" : "Rhythmboat Cruises", "opening_hours" : { "open_now" : false, "weekday_text" : [] }, "photos" : [ { "height" : 426, "html_attributions" : [ "\u003ca href=\"https://www.google.com/maps/views/profile/104066891898402903288\"\u003eRhythmboat Cruises\u003c/a\u003e" ], "photo_reference" : "CmRdAAAA-YL_I_Gk02blOX6S0nKHry8PFu9pDyp3Y9AnqISsa3Eq8mkbdD5mXuu1Fax60s0nSy3iiX-h5j-ztyLHcc1-782MsLQsgLLa4t3ZgDmCMll-a8ABapZGnZwDKByk67LFEhBgedv_u_eYFsEo9ay8jxJjGhTUHKPJ4G82vBJqSNliuv7UlAtclw", "width" : 640 } ], "place_id" : "ChIJyWEHuEmuEmsRm9hTkapTCrk", "reference" : "CnRmAAAAvQlMKw-XtxEY4vWFCvudF7CEMQGI5ycNbfVgGl9rAF75fdiPOiLJw1k9NL2v8ZIJsOJuRS3Lm9Dw1vga4ajycAs7PlxN1MVnnYT9la0pBvEvSQNlyvszKANS1R4P7Mvk_jhqswMggqCUtwJ13LN2hRIQOiAkLTWUi3DOjVVOw7J5IRoUb_cJyJaJNqKdmkDM2f0OjQjh9F0", "scope" : "GOOGLE", "types" : [ "restaurant", "food", "point_of_interest", "establishment" ], "vicinity" : "Pyrmont Bay Wharf (Near Australia Maritime Museum), Pyrmont, NSW 2009" }, { "geometry" : { "location" : { "lat" : -33.867591, "lng" : 151.201196 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png", "id" : "a97f9fb468bcd26b68a23072a55af82d4b325e0d", "name" : "Australian Cruise Group", "opening_hours" : { "open_now" : false, "weekday_text" : [] }, "photos" : [ { "height" : 1331, "html_attributions" : [ "\u003ca href=\"https://www.google.com/maps/views/profile/110751364053842618118\"\u003eAustralian Cruise Group\u003c/a\u003e" ], "photo_reference" : "CmRdAAAAtEoj29FJcNBccrsu6bHt0xgwVGhYlciCY1fe6gTr_d5_KkeP3LITnOwnpNRJWnX39B04-aIBOKXKJH6ltx948T5vWIYBoah1yZDXsWngWZ5kMsK7xyCB5P_q_xBIBxxUEhAYWeB4PiOm_Jy093fB-j0iGhSYmIs9xB2aa6u-RH8V8lZEk-Q5ig", "width" : 2000 } ], "place_id" : "ChIJrTLr-GyuEmsRBfy61i59si0", "reference" : "CnRqAAAAFbukrZvRNsc05TreHUCrPEya5NcN9v0fFLLaK-D1fSyxFTuQlUDhDstU3qwXKw_fADX4W6guUkexax1nufgiYIuGCKoZPEnup1r-LhGGNz9dn1uf9Of5iOtZ1XgCeDjJaYvGbSB3C0pAXL8r9kOsmhIQbx2Sia2DAWTjtSZwuh5aehoUhM6upqBCDLhGruZAGGsCOwAiIq8", "scope" : "GOOGLE", "types" : [ "restaurant", "travel_agency", "food", "point_of_interest", "establishment" ], "vicinity" : "32 The Promenade, King Street Wharf 5, Sydney" }, { "geometry" : { "location" : { "lat" : -33.870943, "lng" : 151.190311 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/bar-71.png", "id" : "e644f7f34cf875b9919c6548f1b721947362850a", "name" : "Lunch Cruise with Jazz on Sydney Harbour", "opening_hours" : { "open_now" : false, "weekday_text" : [] }, "photos" : [ { "height" : 292, "html_attributions" : [ "\u003ca href=\"https://www.google.com/maps/views/profile/105423912060796272053\"\u003eFrom a Google User\u003c/a\u003e" ], "photo_reference" : "CmRdAAAAR4bqFTKYWdBwZwdBdON_JRD7V_joTwwIPwRUpZIZWkSSd8GQ3P2O-_aQbUJdL2RhoAyzCUIF0f--DI4oXFneTpj5zZfFq-iFiT7i_x0tjnDveIY8tJv-6o0uWSSjYqabEhCKqQWZqrKAoddjDcc64N48GhQZ2T1_ntPzNKCooHpZzlYQ7AxFOA", "width" : 438 } ], "place_id" : "ChIJLfySpTOuEmsRPCRKrzl8ZEY", "reference" : "CoQBewAAAFd2fO_YWGTiT4RzXWb5tsOuOt7YyV_ScQOwm0tqJSrAyACCczeOzV-P_mgZLro1oKP_34Nt0nVC_1OEKAQUcd7cUm7xmAMSX-EkbSWiD0kOWGgGgKuDRtb0t_8qsxBGU_izugWCyK7SRWezTxELYNdkS0OEiSWPnvhxvXuQktBBEhAAtEe7fagW2kUR14T1QpVsGhQBO7YpIyYSPvo4zUJuL_bX30nJZw", "scope" : "GOOGLE", "types" : [ "bar", "restaurant", "food", "point_of_interest", "establishment" ], "vicinity" : "37 Bank St, Pyrmont" } ], "status" : "OK" } -LhGGNz9dn1uf9Of5iOtZ1XgCeDjJaYvGbSB3C0pAXL8r9kOsmhIQbx2Sia2DAWTjtSZwuh5aehoUhM6upqBCDLhGruZAGGsCOwAiIq8", { "debug_log" : { "line" : [] }, "html_attributions" : [], "logging_info" : { "experiment_id" : [], "query_geographic_location" : "AU" }, "results" : [ { "geometry" : { "location" : { "lat" : -33.86879, "lng" : 151.194217 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png", "id" : "21a0b251c9b8392186142c798263e289fe45b4aa", "name" : "Rhythmboat Cruises", "opening_hours" : { "open_now" : false, "weekday_text" : [] }, "photos" : [ { "height" : 426, "html_attributions" : [ "\u003ca href=\"https://www.google.com/maps/views/profile/104066891898402903288\"\u003eRhythmboat Cruises\u003c/a\u003e" ], "photo_reference" : "CmRdAAAA-YL_I_Gk02blOX6S0nKHry8PFu9pDyp3Y9AnqISsa3Eq8mkbdD5mXuu1Fax60s0nSy3iiX-h5j-ztyLHcc1-782MsLQsgLLa4t3ZgDmCMll-a8ABapZGnZwDKByk67LFEhBgedv_u_eYFsEo9ay8jxJjGhTUHKPJ4G82vBJqSNliuv7UlAtclw", "width" : 640 } ], "place_id" : "ChIJyWEHuEmuEmsRm9hTkapTCrk", "reference" : "CnRmAAAAvQlMKw-XtxEY4vWFCvudF7CEMQGI5ycNbfVgGl9rAF75fdiPOiLJw1k9NL2v8ZIJsOJuRS3Lm9Dw1vga4ajycAs7PlxN1MVnnYT9la0pBvEvSQNlyvszKANS1R4P7Mvk_jhqswMggqCUtwJ13LN2hRIQOiAkLTWUi3DOjVVOw7J5IRoUb_cJyJaJNqKdmkDM2f0OjQjh9F0", "scope" : "GOOGLE", "types" : [ "restaurant", "food", "point_of_interest", "establishment" ], "vicinity" : "Pyrmont Bay Wharf (Near Australia Maritime Museum), Pyrmont, NSW 2009" }, { "geometry" : { "location" : { "lat" : -33.867591, "lng" : 151.201196 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png", "id" : "a97f9fb468bcd26b68a23072a55af82d4b325e0d", "name" : "Australian Cruise Group", "opening_hours" : { "open_now" : false, "weekday_text" : [] }, "photos" : [ { "height" : 1331, "html_attributions" : [ "\u003ca href=\"https://www.google.com/maps/views/profile/110751364053842618118\"\u003eAustralian Cruise Group\u003c/a\u003e" ], "photo_reference" : "CmRdAAAAtEoj29FJcNBccrsu6bHt0xgwVGhYlciCY1fe6gTr_d5_KkeP3LITnOwnpNRJWnX39B04-aIBOKXKJH6ltx948T5vWIYBoah1yZDXsWngWZ5kMsK7xyCB5P_q_xBIBxxUEhAYWeB4PiOm_Jy093fB-j0iGhSYmIs9xB2aa6u-RH8V8lZEk-Q5ig", "width" : 2000 } ], "place_id" : "ChIJrTLr-GyuEmsRBfy61i59si0", "reference" : "CnRqAAAAFbukrZvRNsc05TreHUCrPEya5NcN9v0fFLLaK-D1fSyxFTuQlUDhDstU3qwXKw_fADX4W6guUkexax1nufgiYIuGCKoZPEnup1r-LhGGNz9dn1uf9Of5iOtZ1XgCeDjJaYvGbSB3C0pAXL8r9kOsmhIQbx2Sia2DAWTjtSZwuh5aehoUhM6upqBCDLhGruZAGGsCOwAiIq8", "scope" : "GOOGLE", "types" : [ "restaurant", "travel_agency", "food", "point_of_interest", "establishment" ], "vicinity" : "32 The Promenade, King Street Wharf 5, Sydney" }, { "geometry" : { "location" : { "lat" : -33.870943, "lng" : 151.190311 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/bar-71.png", "id" : "e644f7f34cf875b9919c6548f1b721947362850a", "name" : "Lunch Cruise with Jazz on Sydney Harbour", "opening_hours" : { "open_now" : false, "weekday_text" : [] }, "photos" : [ { "height" : 292, "html_attributions" : [ "\u003ca href=\"https://www.google.com/maps/views/profile/105423912060796272053\"\u003eFrom a Google User\u003c/a\u003e" ], "photo_reference" : "CmRdAAAAR4bqFTKYWdBwZwdBdON_JRD7V_joTwwIPwRUpZIZWkSSd8GQ3P2O-_aQbUJdL2RhoAyzCUIF0f--DI4oXFneTpj5zZfFq-iFiT7i_x0tjnDveIY8tJv-6o0uWSSjYqabEhCKqQWZqrKAoddjDcc64N48GhQZ2T1_ntPzNKCooHpZzlYQ7AxFOA", "width" : 438 } ], "place_id" : "ChIJLfySpTOuEmsRPCRKrzl8ZEY", "reference" : "CoQBewAAAFd2fO_YWGTiT4RzXWb5tsOuOt7YyV_ScQOwm0tqJSrAyACCczeOzV-P_mgZLro1oKP_34Nt0nVC_1OEKAQUcd7cUm7xmAMSX-EkbSWiD0kOWGgGgKuDRtb0t_8qsxBGU_izugWCyK7SRWezTxELYNdkS0OEiSWPnvhxvXuQktBBEhAAtEe7fagW2kUR14T1QpVsGhQBO7YpIyYSPvo4zUJuL_bX30nJZw", "scope" : "GOOGLE", "types" : [ "bar", "restaurant", "food", "point_of_interest", "establishment" ], "vicinity" : "37 Bank St, Pyrmont" } ], "status" : "OK" } - DI4oXFneTpj5zZfFq-iFiT7i_x0tjnDveIY8tJv-6o0uWSSjYqabEhCKqQWZqrKAoddjDcc64N48GhQZ2T1_ntPzNKCooHpZzlYQ7AxFOA", { "debug_log" : { "line" : [] }, "html_attributions" : [], "logging_info" : { "experiment_id" : [], "query_geographic_location" : "AU" }, "results" : [ { "geometry" : { "location" : { "lat" : -33.86879, "lng" : 151.194217 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png", "id" : "21a0b251c9b8392186142c798263e289fe45b4aa", "name" : "Rhythmboat Cruises", "opening_hours" : { "open_now" : false, "weekday_text" : [] }, "photos" : [ { "height" : 426, "html_attributions" : [ "\u003ca href=\"https://www.google.com/maps/views/profile/104066891898402903288\"\u003eRhythmboat Cruises\u003c/a\u003e" ], "photo_reference" : "CmRdAAAA-YL_I_Gk02blOX6S0nKHry8PFu9pDyp3Y9AnqISsa3Eq8mkbdD5mXuu1Fax60s0nSy3iiX-h5j-ztyLHcc1-782MsLQsgLLa4t3ZgDmCMll-a8ABapZGnZwDKByk67LFEhBgedv_u_eYFsEo9ay8jxJjGhTUHKPJ4G82vBJqSNliuv7UlAtclw", "width" : 640 } ], "place_id" : "ChIJyWEHuEmuEmsRm9hTkapTCrk", "reference" : "CnRmAAAAvQlMKw-XtxEY4vWFCvudF7CEMQGI5ycNbfVgGl9rAF75fdiPOiLJw1k9NL2v8ZIJsOJuRS3Lm9Dw1vga4ajycAs7PlxN1MVnnYT9la0pBvEvSQNlyvszKANS1R4P7Mvk_jhqswMggqCUtwJ13LN2hRIQOiAkLTWUi3DOjVVOw7J5IRoUb_cJyJaJNqKdmkDM2f0OjQjh9F0", "scope" : "GOOGLE", "types" : [ "restaurant", "food", "point_of_interest", "establishment" ], "vicinity" : "Pyrmont Bay Wharf (Near Australia Maritime Museum), Pyrmont, NSW 2009" }, { "geometry" : { "location" : { "lat" : -33.867591, "lng" : 151.201196 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png", "id" : "a97f9fb468bcd26b68a23072a55af82d4b325e0d", "name" : "Australian Cruise Group", "opening_hours" : { "open_now" : false, "weekday_text" : [] }, "photos" : [ { "height" : 1331, "html_attributions" : [ "\u003ca href=\"https://www.google.com/maps/views/profile/110751364053842618118\"\u003eAustralian Cruise Group\u003c/a\u003e" ], "photo_reference" : "CmRdAAAAtEoj29FJcNBccrsu6bHt0xgwVGhYlciCY1fe6gTr_d5_KkeP3LITnOwnpNRJWnX39B04-aIBOKXKJH6ltx948T5vWIYBoah1yZDXsWngWZ5kMsK7xyCB5P_q_xBIBxxUEhAYWeB4PiOm_Jy093fB-j0iGhSYmIs9xB2aa6u-RH8V8lZEk-Q5ig", "width" : 2000 } ], "place_id" : "ChIJrTLr-GyuEmsRBfy61i59si0", "reference" : "CnRqAAAAFbukrZvRNsc05TreHUCrPEya5NcN9v0fFLLaK-D1fSyxFTuQlUDhDstU3qwXKw_fADX4W6guUkexax1nufgiYIuGCKoZPEnup1r-LhGGNz9dn1uf9Of5iOtZ1XgCeDjJaYvGbSB3C0pAXL8r9kOsmhIQbx2Sia2DAWTjtSZwuh5aehoUhM6upqBCDLhGruZAGGsCOwAiIq8", "scope" : "GOOGLE", "types" : [ "restaurant", "travel_agency", "food", "point_of_interest", "establishment" ], "vicinity" : "32 The Promenade, King Street Wharf 5, Sydney" }, { "geometry" : { "location" : { "lat" : -33.870943, "lng" : 151.190311 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/bar-71.png", "id" : "e644f7f34cf875b9919c6548f1b721947362850a", "name" : "Lunch Cruise with Jazz on Sydney Harbour", "opening_hours" : { "open_now" : false, "weekday_text" : [] }, "photos" : [ { "height" : 292, "html_attributions" : [ "\u003ca href=\"https://www.google.com/maps/views/profile/105423912060796272053\"\u003eFrom a Google User\u003c/a\u003e" ], "photo_reference" : "CmRdAAAAR4bqFTKYWdBwZwdBdON_JRD7V_joTwwIPwRUpZIZWkSSd8GQ3P2O-_aQbUJdL2RhoAyzCUIF0f--DI4oXFneTpj5zZfFq-iFiT7i_x0tjnDveIY8tJv-6o0uWSSjYqabEhCKqQWZqrKAoddjDcc64N48GhQZ2T1_ntPzNKCooHpZzlYQ7AxFOA", "width" : 438 } ], "place_id" : "ChIJLfySpTOuEmsRPCRKrzl8ZEY", "reference" : "CoQBewAAAFd2fO_YWGTiT4RzXWb5tsOuOt7YyV_ScQOwm0tqJSrAyACCczeOzV-P_mgZLro1oKP_34Nt0nVC_1OEKAQUcd7cUm7xmAMSX-EkbSWiD0kOWGgGgKuDRtb0t_8qsxBGU_izugWCyK7SRWezTxELYNdkS0OEiSWPnvhxvXuQktBBEhAAtEe7fagW2kUR14T1QpVsGhQBO7YpIyYSPvo4zUJuL_bX30nJZw", "scope" : "GOOGLE", "types" : [ "bar", "restaurant", "food", "point_of_interest", "establishment" ], "vicinity" : "37 Bank St, Pyrmont" } ], "status" : "OK" } -EkbSWiD0kOWGgGgKuDRtb0t_8qsxBGU_izugWCyK7SRWezTxELYNdkS0OEiSWPnvhxvXuQktBBEhAAtEe7fagW2kUR14T1QpVsGhQBO7YpIyYSPvo4zUJuL_bX30nJZw", { "debug_log" : { "line" : [] }, "html_attributions" : [], "logging_info" : { "experiment_id" : [], "query_geographic_location" : "AU" }, "results" : [ { "geometry" : { "location" : { "lat" : -33.86879, "lng" : 151.194217 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png", "id" : "21a0b251c9b8392186142c798263e289fe45b4aa", "name" : "Rhythmboat Cruises", "opening_hours" : { "open_now" : false, "weekday_text" : [] }, "photos" : [ { "height" : 426, "html_attributions" : [ "\u003ca href=\"https://www.google.com/maps/views/profile/104066891898402903288\"\u003eRhythmboat Cruises\u003c/a\u003e" ], "photo_reference" : "CmRdAAAA-YL_I_Gk02blOX6S0nKHry8PFu9pDyp3Y9AnqISsa3Eq8mkbdD5mXuu1Fax60s0nSy3iiX-h5j-ztyLHcc1-782MsLQsgLLa4t3ZgDmCMll-a8ABapZGnZwDKByk67LFEhBgedv_u_eYFsEo9ay8jxJjGhTUHKPJ4G82vBJqSNliuv7UlAtclw", "width" : 640 } ], "place_id" : "ChIJyWEHuEmuEmsRm9hTkapTCrk", "reference" : "CnRmAAAAvQlMKw-XtxEY4vWFCvudF7CEMQGI5ycNbfVgGl9rAF75fdiPOiLJw1k9NL2v8ZIJsOJuRS3Lm9Dw1vga4ajycAs7PlxN1MVnnYT9la0pBvEvSQNlyvszKANS1R4P7Mvk_jhqswMggqCUtwJ13LN2hRIQOiAkLTWUi3DOjVVOw7J5IRoUb_cJyJaJNqKdmkDM2f0OjQjh9F0", "scope" : "GOOGLE", "types" : [ "restaurant", "food", "point_of_interest", "establishment" ], "vicinity" : "Pyrmont Bay Wharf (Near Australia Maritime Museum), Pyrmont, NSW 2009" }, { "geometry" : { "location" : { "lat" : -33.867591, "lng" : 151.201196 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png", "id" : "a97f9fb468bcd26b68a23072a55af82d4b325e0d", "name" : "Australian Cruise Group", "opening_hours" : { "open_now" : false, "weekday_text" : [] }, "photos" : [ { "height" : 1331, "html_attributions" : [ "\u003ca href=\"https://www.google.com/maps/views/profile/110751364053842618118\"\u003eAustralian Cruise Group\u003c/a\u003e" ], "photo_reference" : "CmRdAAAAtEoj29FJcNBccrsu6bHt0xgwVGhYlciCY1fe6gTr_d5_KkeP3LITnOwnpNRJWnX39B04-aIBOKXKJH6ltx948T5vWIYBoah1yZDXsWngWZ5kMsK7xyCB5P_q_xBIBxxUEhAYWeB4PiOm_Jy093fB-j0iGhSYmIs9xB2aa6u-RH8V8lZEk-Q5ig", "width" : 2000 } ], "place_id" : "ChIJrTLr-GyuEmsRBfy61i59si0", "reference" : "CnRqAAAAFbukrZvRNsc05TreHUCrPEya5NcN9v0fFLLaK-D1fSyxFTuQlUDhDstU3qwXKw_fADX4W6guUkexax1nufgiYIuGCKoZPEnup1r-LhGGNz9dn1uf9Of5iOtZ1XgCeDjJaYvGbSB3C0pAXL8r9kOsmhIQbx2Sia2DAWTjtSZwuh5aehoUhM6upqBCDLhGruZAGGsCOwAiIq8", "scope" : "GOOGLE", "types" : [ "restaurant", "travel_agency", "food", "point_of_interest", "establishment" ], "vicinity" : "32 The Promenade, King Street Wharf 5, Sydney" }, { "geometry" : { "location" : { "lat" : -33.870943, "lng" : 151.190311 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/bar-71.png", "id" : "e644f7f34cf875b9919c6548f1b721947362850a", "name" : "Lunch Cruise with Jazz on Sydney Harbour", "opening_hours" : { "open_now" : false, "weekday_text" : [] }, "photos" : [ { "height" : 292, "html_attributions" : [ "\u003ca href=\"https://www.google.com/maps/views/profile/105423912060796272053\"\u003eFrom a Google User\u003c/a\u003e" ], "photo_reference" : "CmRdAAAAR4bqFTKYWdBwZwdBdON_JRD7V_joTwwIPwRUpZIZWkSSd8GQ3P2O-_aQbUJdL2RhoAyzCUIF0f--DI4oXFneTpj5zZfFq-iFiT7i_x0tjnDveIY8tJv-6o0uWSSjYqabEhCKqQWZqrKAoddjDcc64N48GhQZ2T1_ntPzNKCooHpZzlYQ7AxFOA", "width" : 438 } ], "place_id" : "ChIJLfySpTOuEmsRPCRKrzl8ZEY", "reference" : "CoQBewAAAFd2fO_YWGTiT4RzXWb5tsOuOt7YyV_ScQOwm0tqJSrAyACCczeOzV-P_mgZLro1oKP_34Nt0nVC_1OEKAQUcd7cUm7xmAMSX-EkbSWiD0kOWGgGgKuDRtb0t_8qsxBGU_izugWCyK7SRWezTxELYNdkS0OEiSWPnvhxvXuQktBBEhAAtEe7fagW2kUR14T1QpVsGhQBO7YpIyYSPvo4zUJuL_bX30nJZw", "scope" : "GOOGLE", "types" : [ "bar", "restaurant", "food", "point_of_interest", "establishment" ], "vicinity" : "37 Bank St, Pyrmont" } ], "status" : "OK" } 

The following example is a list of hospitals near London, England.

 https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=51.503186,-0.126446&radius=5000&types=hospital&key=API_KEY 

See here for more details.

+14
source

Follow this link, everything was explained

in String type = 'grocery_or_supermarket' replace it with "hospital" and you will be fine:

http://androidmastermind.blogspot.co.ke/2016/06/android-google-maps-with-nearyby-places.html

+2
source
  private void loadNearByPlaces(double latitude, double longitude) //YOU Can change this type at your own will, eg hospital, cafe, restaurant.... and see how it all works { mMap.clear(); Intent i = getIntent(); String type = hospital; StringBuilder googlePlacesUrl = new StringBuilder("https://maps.googleapis.com/maps/api/place/nearbysearch/json?"); googlePlacesUrl.append("location=").append(latitude).append(",").append(longitude); googlePlacesUrl.append("&radius=").append(PROXIMITY_RADIUS); googlePlacesUrl.append("&types=").append(type); googlePlacesUrl.append("&sensor=true"); googlePlacesUrl.append("&key=" + GOOGLE_BROWSER_API_KEY); JsonObjectRequest request = new JsonObjectRequest(googlePlacesUrl.toString(), new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject result) { Log.i(TAG, "onResponse: Result= " + result.toString()); parseLocationResult(result); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.e(TAG, "onErrorResponse: Error= " + error); Log.e(TAG, "onErrorResponse: Error= " + error.getMessage()); } }); AppController.getInstance().addToRequestQueue(request); } 

This will load the nearest hospital according to your location.

0
source

All Articles