1

複数のマーカーが存在するセットアップがあり、クリックするとそれぞれが単一の InfoWindow にコンテンツをロードします。

残念ながら、別のウィンドウが開いているときにマーカーをクリックすると、マーカーのクリック イベントが発生しないようです。

これは奇妙な動作のようです。他の誰かがこれに当てはまることを発見しましたか?

ありがとう

以下の私のコード:

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

if(markers) {
    var length = markers.length;
    for(var i = 0; i < length; i++) {
        var details = markers[i];
        markers[i] = new google.maps.Marker({
            title: details.name,
            position: new google.maps.LatLng(details.location[0],details.location[1]),
            locCode: details.locCode
        });
        markers[i].setMap(map);
        var thisMarker = markers[i];
        google.maps.event.addListener(thisMarker, 'click', (function(thisMarker, i, details) {
            // self calling function was the key to get this to work
            return function() {
                $.ajax({
                    url: 'js/locations/'+details.locCode+'.js',
                    dataType: 'script',
                    success: function(data) {
                        // do my specific stuff here, basically adding html to the info-window div via jQuery

                        // set the content, and open the info window
                        infoWindow.setContent($("#info-window").html());
                        infoWindow.open(map, thisMarker);
                    }
                });
            }
          })(thisMarker, i, details));
    }
}
4

1 に答える 1

0

ここで私の答えをチェックしてください:

Jquery Google Maps V3 - 情報ウィンドウは常に 1 つのマーカーに固定されます

これが問題の解決に役立つと思います。

ボブ

于 2011-07-21T21:25:26.403 に答える