Skip to content

Commit

Permalink
feat: close map
Browse files Browse the repository at this point in the history
  • Loading branch information
dmvieira committed Apr 1, 2024
1 parent 49e4e5f commit eec7518
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,21 @@ function initMap(position) {
return response.json();
})
.then(function(places){
var markers = [];
for (var i in places) {
var place = places[i];
createMarker(
place.name, place.geo, place.url, place.food, place.food_desc, place.work_hours, place.contact);
markers.push(createMarker(
place.name, place.geo, place.url, place.food, place.food_desc, place.work_hours, place.contact));
};
return markers
})
.then(function(markers){
google.maps.event.addListener(map, "click", function(event) {
for (var i = 0; i < markers.length; i++ ) {
markers[i].close();
}
})

})
}

function checkAndInit(){
Expand Down Expand Up @@ -63,6 +71,7 @@ function createMarker(name, geo, url, food, foodDesc, workHours, contact) {
marker.addListener('click', function() {
infowindow.open(map, marker);
});
return infowindow;
}

window.initMap = checkAndInit;

0 comments on commit eec7518

Please sign in to comment.