Python | Fetch Nearest Hospital locations using GoogleMaps API Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report If you are ever curious about how you can fetch nearest places (restaurant, hospital, labs, cafe's, etc) location using your current location, this could be achieved using Python and Google Maps API. In this article, we will use Google Maps API to find the nearest hospital's locations using Python. The API Key can be generated using the google developers console. Then you should follow the steps there to make an API Key. Implementation: Install the required python libraries before running the code: googleplaces, requestsCreate an google Maps API Key going to this link.Initialize Google Places constructor as: google_places = GooglePlaces(API_KEY) Call this function google_places.nearby_search with parameters as latitude, longitude, radius and type:{hospital, casino, bar, cafe, etc} and store the output in a variable. User can give his own latitude and longitude in the parameters.The search results will be of class type: 'googleplaces.Place'.The attribute's value can be printed like longitude, latitude, name Below is the implementation code : Python3 # Importing required libraries from googleplaces import GooglePlaces, types, lang import requests import json # This is the way to make api requests # using python requests library # send_url = 'http://freegeoip.net/json' # r = requests.get(send_url) # j = json.loads(r.text) # print(j) # lat = j['latitude'] # lon = j['longitude'] # Generate an API key by going to this location # https://cloud.google.com/ /maps-platform/places/?apis = # places in the google developers # Use your own API key for making api request calls API_KEY = 'Your_API_Key' # Initialising the GooglePlaces constructor google_places = GooglePlaces(API_KEY) # call the function nearby search with # the parameters as longitude, latitude, # radius and type of place which needs to be searched of # type can be HOSPITAL, CAFE, BAR, CASINO, etc query_result = google_places.nearby_search( # lat_lng ={'lat': 46.1667, 'lng': -1.15}, lat_lng ={'lat': 28.4089, 'lng': 77.3178}, radius = 5000, # types =[types.TYPE_HOSPITAL] or # [types.TYPE_CAFE] or [type.TYPE_BAR] # or [type.TYPE_CASINO]) types =[types.TYPE_HOSPITAL]) # If any attributions related # with search results print them if query_result.has_attributions: print (query_result.html_attributions) # Iterate over the search results for place in query_result.places: print(place) # place.get_details() print (place.name) print("Latitude", place.geo_location['lat']) print("Longitude", place.geo_location['lng']) print() Output: Sarvodaya Hospital Latitude 28.4222361 Longitude 77.3167904 Metro Heart Institute with Multispeciality Latitude 28.4060327 Longitude 77.31803429999999 Asian Institute of Medical Sciences Latitude 28.4260095 Longitude 77.29998359999999 Rawat Medical Store Latitude 28.3928114 Longitude 77.30199 Sparsh Hospital Latitude 28.4449953 Longitude 77.31859759999999 ..more results Comment More infoAdvertise with us Next Article How to download Google Images using Python M md1844 Follow Improve Article Tags : Python python-utility Web-API Practice Tags : python Similar Reads Plotting Data on Google Map using Python's pygmaps package pygmaps is a matplotlib-like interface to generate the HTML and javascript to render all the data users would like on top of Google Maps. Command to install pygmaps : pip install pygmaps (on windows)sudo pip3 install pygmaps (on linix / unix)Code #1 : To create a Base Map. Python # import required p 3 min read Python | Plotting Google Map using gmplot package gmplot is a matplotlib-like interface to generate the HTML and javascript to render all the data user would like on top of Google Maps. Command to install gmplot : pip install gmplotCode #1 : To create a Base Map Python # import gmplot package import gmplot # GoogleMapPlotter return Map object # Pas 2 min read Python | Plotting Google Map using folium package Folium is built on the data wrangling strengths of the Python ecosystem and the mapping strengths of the Leaflet.js (JavaScript) library. Simply, manipulate your data in Python, then visualize it on a leaflet map via Folium. Folium makes it easy to visualize data that's been manipulated in Python, o 2 min read How to download Google Images using Python Python is a multi-purpose language and widely used for scripting. We can write Python scripts to automate day-to-day things. Letâs say we want to download google images with multiple search queries. Instead of doing it manually we can automate the process. How to install needed Module :Â pip install 2 min read Extracting locations from text using Python In this article, we are going to see how to extract location from text using Python. While working with texts, the requirement can be the detection of cities, regions, states, and countries and relationships between them in the received text. This can be very useful for geographical studies. In this 3 min read Python script to open a Google Map location on clipboard The task is to create a python script that would open the default web browser to the Google map of the address given as the command line argument. Following is the step by step process:Â Creating the Address_string from command line input :Â Command line arguments can be read through sys module. The 3 min read Like