javascript - 仅当未显示弹出窗口时才在悬停时显示传单工具提示
问题描述
我有一个带有简短文本描述的工具提示和一个带有较长格式描述的弹出窗口,该描述绑定到传单地图上的标记。
悬停时显示工具提示,单击位置标记时显示弹出窗口。当较大的弹出窗口可见时,无需显示工具提示。当弹出窗口可见时,我可以禁用工具提示吗?我该怎么做?
这是我到目前为止的代码:
var marker = L.marker(location);
marker.bindPopup("Long description with extra formatting ...");
marker.bindTooltip("Short description");
解决方案
您可以为工具提示和弹出窗口添加自定义处理程序。使用返回 true 或 false 的传单方法isPopupOpen()
,您可以决定是否打开工具提示。
function customTip() {
this.unbindTooltip();
if(!this.isPopupOpen()) this.bindTooltip('Short description').openTooltip();
}
function customPop() {
this.unbindTooltip();
}
var marker = L.marker(location);
marker.bindPopup('Long description with extra formatting ...');
marker.on('mouseover', customTip);
marker.on('click', customPop);
推荐阅读
- python - 如何使用python3中的异常处理从文件夹中删除特定图像
- html - 如何使用css调整元素的背景图像以适应全屏?
- php - Cassandra db PHP 驱动程序,不能使用 ORDER BY 和对分区键的 IN 限制分页查询
- r - Rcpp 中出现 FREESXP 节点错误的原因是什么?
- python - 分号中的辅助行中的语法无效:E4_Email
- laravel - laravel 5.4 中的关系
- android - 如何将许可证文本添加到开源许可证插件?
- mysql - sql查询不返回表中的非唯一值
- asp.net - 如果登录用户是管理员,如何防止普通用户访问其他用户数据并允许访问其他数据?
- mule - Salesforce 连接器中的命名参数查询 Single Mule 4