传单图层控件仅在单击时打开 [英] Leaflet layer control open only on click

查看:12
本文介绍了传单图层控件仅在单击时打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法只在点击时打开传单图层控件?

Is there any way to open leaflet layer control only when clicked?

默认情况下,它在鼠标悬停/鼠标移出时展开/折叠.我只想在点击时打开.

By default, it expands/collapse when on mouseover/mouseout. I want to open only on click.

推荐答案

鼠标悬停停止传播解决了这个问题.我在这里使用 d3,但它可以通过普通的 javascript 或 jQuery 轻松处理.

Stop propagation on mouse over solved it. I am using d3 here but It can be easily handled by plain javascript or by jQuery.

d3.select(".leaflet-control-layers-toggle").on("mouseover", function () {
        //this will make sure that layer popup menu
        //not opens when mouseover
        d3.event.stopPropagation();
    });

这篇关于传单图层控件仅在单击时打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆