Search code examples
javascriptgoogle-mapsgoogle-maps-api-3infobox

Google Maps Infobox - need to only show on click


I have a google map on the home: http://veganinbudapest.com/

Basically an infobox shows for every listing, however I would like it hidden until you click on a marker then it should show.

Here are my settings for the infobox, maybe someone can help me work out that code.

var myOptions = {
         content: boxText
        ,disableAutoPan: false
        ,maxWidth: 0
        ,pixelOffset: new google.maps.Size(maph, mapw)
        ,zIndex: null
        ,boxStyle: {             
          opacity: 0.8
          ,width: "160px"
         }
        ,closeBoxMargin: ""
        ,closeBoxURL: ""
        ,infoBoxClearance: new google.maps.Size(1, 1)
        ,isHidden: false
        ,pane: "floatPane"
        ,enableEventPropagation: false
    };

    google.maps.event.addListener(marker, "click", function (e) {
        ib.open(map, this);
    });

    var ib = new InfoBox(myOptions);
    ib.open(map, marker);

Solution

  • Maybe your last line with ib.open(map, marker) opens it? I can't comment yet but it seems to open on initiation.