Search code examples
javascriptgoogle-mapsgoogle-maps-markersinfowindow

Is it possible to open multiple infoWindows for one marker in google maps api?


I am working on a project, and they want to look the infowindows like this:

[![enter image description here][1]][1]

How is this possible and which library would you recommend?


Solution

  • In Google maps v3 it is possible by creating custom event listeners and modifying autocentering. Examples can be found here: http://you.arenot.me/2010/06/29/google-maps-api-v3-0-multiple-markers-multiple-infowindows/

    Several infowindows for one marker (not tested):

    var infowindow = new google.maps.InfoWindow();
    var infowindow2 = new google.maps.InfoWindow();
    var marker = new google.maps.Marker({
      position:latLng,
      map: map
    });
    
    google.maps.event.addListener(marker, 'click', function(content){
      return function(){
        infowindow.setContent(content);
        infowindow.open(map, this);
        infowindow2.setContent(content+'222');
        infowindow2.open(map, this);
      }
    }(content));