/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
JavaScript
let map;
let service;
let infowindow;
let userPosition = {
lat: 40.7127753,
lng: -74.0059728
}
function initialize() {
infowindow = new google.maps.InfoWindow();
//Map options
var options = {
center: userPosition,
zoom: 15,
// disableDefaultUI: true,
}
//New map
map = new
google.maps.Map(document.getElementById("map"), options);
var requestF = {
location: userPosition,
radius: '2000',
query: 'pharmacy',
};
service = new google.maps.places.PlacesService(map);
service.textSearch(requestF, callbackF);
var requestH = {
location: userPosition,
radius: '2000',
query: 'hospital',
};
service.textSearch(requestH, callbackH);
function addUserLocationMarker() {
marker = new google.maps.Marker({
map,
draggable: true,
animation: google.maps.Animation.DROP,
position: userPosition,
icon: "http://maps.google.com/mapfiles/kml/pushpin/grn-pushpin.png"
});
marker.addListener("click", toggleBounce);
var infoWindow = new google.maps.InfoWindow({
content: "<h3>Locatia mea ! 🙂</h3>"
});
marker.addListener('click', function() {
infoWindow.open(map, marker);
});
}
addUserLocationMarker();
}
function callbackF(results, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {
var place = results[i];
// createMarker(results[i]);
drop(results, "F");
}
}
}
function callbackH(results, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {
var place = results[i];
// createMarker(results[i]);
drop(results, "H");
}
}
}
let markers = [];
function drop(neighborhoods, label) {
clearMarkers();
for (let i = 0; i < neighborhoods.length; i++) {
addMarkerWithTimeout(neighborhoods[i], label, i * 200);
}
}
function addMarkerWithTimeout(place, label, timeout) {
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.