dburles / dburles/reactive-maps-example

Close all open infowindows

Open
#2 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
29
Forks
19
PR merge metrics
No merged PRs in 30d

Description

I have created some markers based on reactive-maps-example code and i am displaying a marker on click this way

```
var infoWindow = new google.maps.InfoWindow({
content: "content holder.."
});
google.maps.event.addListener(marker, 'click', function () {
infoWindow.close();
infoWindow.open(map.instance, marker);
//console.log(markers);
});
```

When i click on a marker,an info window is created but when i click another marker,another infowindow pos up,therefore having multiple infowindows open when i click other markers. I would like to close all open info windows upon clicking a marker.

I have tried the code below but its not working. Anyone has any clue on how to display an infowindow at a time?.

```
for(var i = 0; i < markers.length; i++){
var marker = markers[i]; google.maps.event.addListener(marker, 'click', function () { infoWindow.close(); infoWindow.open(map.instance, marker); //console.log(markers); }); }
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.