Skip to content

Instantly share code, notes, and snippets.

@thenerdsuperuser
Created March 30, 2019 15:00
Show Gist options
  • Save thenerdsuperuser/2904bc86424e8bf31b2dec77f02d3ee0 to your computer and use it in GitHub Desktop.
Save thenerdsuperuser/2904bc86424e8bf31b2dec77f02d3ee0 to your computer and use it in GitHub Desktop.
This js function returns a list of all the nearby hospitals which are marked as safe zones and prints them out.
YOUR_API_KEY = ''
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places"></script>
var map;
var service;
var infowindow;
function initialize() {
var pyrmont = new google.maps.LatLng(-33.8665433,151.1956316);
map = new google.maps.Map(document.getElementById('map'), {
center: pyrmont,
zoom: 15
});
var request = {
location: pyrmont,
radius: '500',
query: 'hospital'
};
service = new google.maps.places.PlacesService(map);
service.textSearch(request, callback);
}
function callback(results, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {
var place = results[i];
createMarker(results[i]);
}
}
}
@thenerdsuperuser
Copy link
Author

In line 10, pass in your current geo_loc

and replace the empty string with your api key in line 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment