Google maps api setContent открывает несколько информационных окон - PullRequest
0 голосов
/ 20 октября 2018

Я новичок в Google Maps API.Из того, что я понимаю, при использовании infowindow.setContent () у вас должно быть открыто только одно информационное окно за раз.Однако, когда открывается новое окно, старое (ие) остается открытым.Я также использую response.js

makeMarkers = (locations) => {
  locations.map(brewery => {
  let marker = new window.google.maps.Marker({
  position: {lat: brewery.location.lat, lng: brewery.location.lng},
  map: this.state.mapNJ,
  title: brewery.name,
  animation: window.google.maps.Animation.DROP,
  id: brewery.id,
  })
  let infowindow =  new window.google.maps.InfoWindow({
   maxWidth: 250
  })
    marker.addListener('click', function() {    
    marker.setAnimation(window.google.maps.Animation.BOUNCE);
      setTimeout(() => 
    marker.setAnimation(null), 1400);
      BreweryAPI.getBreweryInfo(brewery.id)
      .then(data => {
          checkData(marker, data);
          getInfoContent(marker);
        })
      .catch(() => getErrorContent(marker))
      .finally(() => {
    infowindow.setContent(marker.infoContent);
        infowindow.open(this.map, marker);
        })
    });
  });
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...