【问题标题】:Closing angular-leaflet popups on event关闭事件的角传单弹出窗口
【发布时间】:2014-12-12 21:04:52
【问题描述】:

我可以调用一个函数来关闭 angular-leaflet 指令中所有打开的弹出窗口吗?根据here 的 jQuery 建议工作,我尝试了以下方法:

document.getElementsByClassName('.leaflet-popup-close-button').click();

但我明白了

TypeError: undefined is not a function

或者,我尝试过:

document.getElementsByClassName('.leaflet-popup-close-button')[0].click();

但这也不起作用:

TypeError: Cannot read property 'click' of undefined

【问题讨论】:

    标签: angularjs leaflet angular-leaflet-directive


    【解决方案1】:

    查看原始 Leaflet 文档,解决方案是获取本机 Leaflet 地图对象并在其上调用函数。

                leafletData.getMap().then(function(map) {
                    map.closePopup();
                });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多