Search code examples
javascripthtmlgoogle-maps-api-3

How to find nearby hospitals using google map api and javascript


var MapApiApplication = {
   myCurrentPosition : "",
   mapOptions : "",
   marker : "",
   initialize : function(){
      MapApiApplication.myCurrentPosition = new google.maps.LatLng(10.112293000000000000, 76.352684500000010000);
      MapApiApplication.mapOptions = {
        zoom: 13,
        center: MapApiApplication.myCurrentPosition,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      };
      MapApiApplication.map = new google.maps.Map(document.getElementById('map-canvas'), MapApiApplication.mapOptions);
      MapApiApplication.marker = new google.maps.Marker({
         position: MapApiApplication.myCurrentPosition,
         map: MapApiApplication.map,
         title: 'Here You are'
      });
   }, 
}; 

I have the current position's latitude and longitude. How can i find nearby hospitals locations using only javascript and google maps api.


Solution

  • You need to use the Places Library. In the Place Search Requests you can specify a type - which categorizes what "type" of place you are searching for. According to the Supported Place Types by Google Places API, there are hospital and health types - which would probably be your best bet to get hospitals in your search response.