0
我正在創建一個谷歌地圖,其中標記在點擊(infoWindow)上顯示一個彈出窗口。由於我在Bootstrap上開發這個頁面,我想在用戶點擊infoWindow時顯示一個模式對話框。你知道如何做到這一點,以及如何將參數傳遞給模態?如何將參數從infoWindow傳遞給模態對話框?
這裏是我的HTML代碼:
<div class="modal fade" id="userDetails" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="userDetailsTitle"></h4>
</div>
<div class="modal-body">
<p id="userDetailsDesc"></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
這裏是我的Javascript代碼:
google.maps.event.addListener(marker, "click", function (e) {
infoWindow.setContent("<div id='info' data-toggle='modal' data-target='#userDetails'><p id='title'>" + data.title + "</p><p>" + data.desc + "</p></div>");
infoWindow.open(map, marker);
});
這會觸發模式,當用戶點擊信息窗口彈出。現在如何將更多參數傳遞給模態對話框?我的意思是我可以從data.city
,data.phone
,data.phone
等等獲得的內容... 我在SO和Google上搜索和搜索,但似乎沒有一個適合我的代碼,也許是因爲我試圖從infoWindow觸發模式。
可以在此添加更多的細節。 infoWindow是指什麼? – wallop
你解決了嗎? – doxsi
是的,請參考我的回答。對不起,延遲...我希望你仍然需要它。 – smartmouse