Created
March 30, 2019 15:00
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In line 10, pass in your current geo_loc
and replace the empty string with your api key in line 1