Remove all InfoWindow in google maps

0

How do I remove all info.window in google maps.

Most examples are as follows:

var infowindow = null;

incia

se clicar

if(infowindow){
        infowindow.close();
}

My code looks like this:

<script>
var infowindow = null;

// Remaining google maps code ...

  map.data.addListener('click', function(event) {

    if(infowindow){
        infowindow.close();
    }
    var infoWindow = new google.maps.InfoWindow();
    var iwContent = 'FOI';

    infoWindow.setContent(iwContent);
    var lat = event.latLng.lat();
    var lng = event.latLng.lng();
    infoWindow.setPosition(new google.maps.LatLng(lat,lng));     
    infoWindow.open(map);

  });

How do I fix it? because it only returns the NULL variable ...

    
asked by anonymous 18.04.2015 / 01:14

1 answer

-1

To work I have to do the following:

 map.data.addListener('click', function(event) {

    if(infoWindow){
        infoWindow.close();
    }

    var iwContent = 'FOI';
    infoWindow.setContent(iwContent);
    var lat = event.latLng.lat();
    var lng = event.latLng.lng();
    infoWindow.setPosition(new google.maps.LatLng(lat,lng));     
    infoWindow.open(map);   
  });


  var infoWindow = new google.maps.InfoWindow();

ATT

    
19.04.2015 / 15:04