检测Leaflet Map是否处于全屏模式 [英] Detecting if Leaflet Map is in Full Screen mode or not
问题描述
有人知道如何检测单张地图是否设置为全屏吗?因此,此处是我正在使用的示例.我希望能够检测用户是否处于全屏状态. 我已经尝试过了:
Does anyone know how to detect if a leaflet map is set to fullscreen? So here is an example I am playing with. I want to be able to detect if the user is in the fullscreen state. I have tried this:
$(".leaflet-control-zoom-fullscreen").click(function(e){
console.log(e);
if(e.clientX <=20){
$("#dashboardA").show();
}else if(e.clientX > 150){
$("#dashboardA").hide();
}else{
$("#dashboardA").show();
}
});
以上代码可以正常工作.但是我觉得有更好的方法可以做到这一点. 例如,假设我要在地图上显示某些内容,并希望在用户在全屏模式和普通模式之间移动时隐藏/显示该内容.我将如何有效地做到这一点? 非常感谢.
The above code sort of works.But i get the feeling there is a better way to do this. For example, let's say I am displaying something on the map and want to hide/show it when the user moves between fullscreen and normal mode. How would i do this effectively? Thanks so much.
推荐答案
如果使用传单.全屏插件,您可以调用map.isFullscreen()
来获取地图的全屏状态.
If you use the Leaflet.fullscreen plugin instead, you can call map.isFullscreen()
to get the map's fullscreen status.
这篇关于检测Leaflet Map是否处于全屏模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!