Magnific-popup nie otwiera się z przycisku w Google Maps infoBox

Mam infoBox, który otwiera się po kliknięciu znacznika Google Maps. Wewnątrz infoBoxu znajduje się przycisk „# open-popup”, który po kliknięciu powinien otworzyć okno modalne magnificPopup, ale nic się nie dzieje.

Jako test umieściłem ten sam przycisk poza div zawierający mapę google, która otwiera okno modalne, ale tylko po drugim kliknięciu! Co się dzieje?

Próbowałem wszystkiego od wielu dni, ale wszystkie mają najgorsze skutki uboczne.

Każda pomoc zostanie bardzo doceniona.

HTML dla przycisku wewnątrz infoBox:

<div style=...>
<centre>
<button id="open-popup">Open popup</button>
<div id="my-popup" class="mfp-hide white-popup">Inline popup</div>
</center>
</div>

HTML dla przycisku poza google maps div:

<button id="open-popup">Open popup</button>
<div id="my-popup" class="mfp-hide white-popup">Inline popup</div>

JS:

myapp.triggerClick = function (){
  google.maps.event.trigger(gmarkers[id],"click")
};

var infoboxOptions = {
             content: ''
            ,disableAutoPan: false
            ,alignBottom: true
            ,maxWidth: 0
            ,pixelOffset: new google.maps.Size(0, 0)
            ,zIndex: 1000
            ,boxStyle: {
              background:''
              ,opacity: 0.9
             }
            ,closeBoxMargin: "4px 4px 0 0"
            ,closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif"
            ,infoBoxClearance: new google.maps.Size(1,1)
            ,isHidden: false
            ,pane: "floatPane"
            ,enableEventPropagation: false
        };
var ib = new InfoBox(infoboxOptions);

function createMarker(latlng, html, id) {
    var contentString = html;
    var marker = new google.maps.Marker({
        position: latlng,
        map: map
        //zIndex: Math.round(latlng.lat()*-100000)<<5
        });

    google.maps.event.addListener(marker, 'click', function() {
      ib.setContent(contentString);
      ib.open(map,marker);
    });
    gmarkers[id] = marker;
}

$(document).on('click', '#open-popup', function () {
    $(this).magnificPopup({
      items: {
        src: 'http://upload.wikimedia.org/wikipedia/commons/thumb/6/64/Peter_%26_Paul_fortress_in_SPB_03.jpg/800px-Peter_%26_Paul_fortress_in_SPB_03.jpg'
      },
      type: 'image' // this is default type
    });
});

questionAnswers(1)

yourAnswerToTheQuestion