2 回答

TA貢獻(xiàn)1878條經(jīng)驗 獲得超4個贊
是的,有辦法。您可以向每個標(biāo)記添加單擊事件,然后添加彈出窗口。
var fg = L.featureGroup().addTo(map);
var m1 = L.marker([51.505, -0.09]).addTo(fg);
var v1 = '<div id="v1">v1</div>';
m1.popcontent = v1; //custom property to safe the html to the marker
var m2 = L.marker([51.505, -0.094]).addTo(fg);
var v2 = '<div id="v2">v2</div>';
m2.popcontent = v2;
var m3 = L.marker([51.505, -0.096]).addTo(fg);
var v3 = '<div id="v3">v3</div>';
m3.popcontent = v3;
fg.on('click',function(e){
var layer = e.layer;
layer.bindPopup(layer.popcontent).openPopup();
});
如果您的 html 在 vegaEmbed 中更新,您必須將 html ID 保存到標(biāo)記中,然后將其讀出。
var m1 = L.marker([51.505, -0.09]).addTo(fg);
var v1 = 'v1';
m1.popcontent = v1; //custom property to safe the id to the marker
fg.on('click',function(e){
var layer = e.layer;
layer.bindPopup($("#"+layer.popcontent).html()).openPopup(); // or document.getElementById(layer.popcontent).innerHTML;
});
示例:https://jsfiddle.net/falkedesign/56dLkq9h/

TA貢獻(xiàn)1831條經(jīng)驗 獲得超4個贊
如果我理解正確(我可能不理解),您希望生成“光”以某種方式動態(tài)地從 folium 代碼中獲取 html 代碼。如果這是問題的話,答案是否定的。你不能。
來自Folium 文檔:
folium 建立在 Python 生態(tài)系統(tǒng)的數(shù)據(jù)處理優(yōu)勢和 leaflet.js 庫的映射優(yōu)勢之上。在 Python 中操作數(shù)據(jù),然后通過 folium 在 Leaflet 地圖上將其可視化。
事實上,您的觀點在某種程度上是眾所周知的觀點。
- 2 回答
- 0 關(guān)注
- 240 瀏覽
添加回答
舉報