あなたがやりたいことをするためのプラグインがそこにあるかもしれませんが、プラグインなしで行うことも可能です. 私は私のプロジェクトの1つでそのようなことをしました。
- 各マーカーにイベント リスナーを追加します。クリックするとマーカーリスト情報ウィンドウが開きます
- マーカー リスト情報ウィンドウのコンテンツには、マーカー情報ウィンドウ
onclick
を開く属性が含まれています。
私のコードは関数に隠されていましたが、基本的にはこれだけでした:
//1) while creating marker, create click listener that opens the marker list
google.maps.event.addListener(marker, 'click', function() {
markerWindow.close();
markerList.open(map, marker);
});
//2) store the content required by the marker's info windows
var markers = [
[marker1Reference, "The Stadium"],
[maerker2Reference, "The Supermarket"]
];
//3) the function that is called each time a marker is chosen from the marker list
function openMarkerInfo(markerIndex) {
markerList.close();
markerWindow.setContent(markers[markerIndex][1]);
markerWindow.open(map, markers[markerIndex][0]);
}
//4) info window for the marker list - the content includes JS onclick events that will open each marker info window
markerList = new google.maps.InfoWindow({
content: "Choose:<br><br><div href='' class='markerLink' onclick='openMarkerInfo(0)'>The Stadium</div><br><div href='' class='markerLink' onclick='openMarkerInfo(1)'>My House</div>"
});
//5) the marker window that will get set each time a marker is clicked in the list
markerWindow = new google.maps.InfoWindow();
それが役立つことを願っています!