Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Leaflet 我可以更改单张弹出事件处理程序吗?_Leaflet - Fatal编程技术网

Leaflet 我可以更改单张弹出事件处理程序吗?

Leaflet 我可以更改单张弹出事件处理程序吗?,leaflet,Leaflet,当前的默认行为是,当弹出窗口绑定到的层被单击时,弹出窗口将打开,我想将此单击事件更改为上下文菜单事件。我正在使用layer.bindpopup函数,我看不出如何使用选项来实现这一点 您可以绑定其他处理程序,也可以不绑定弹出窗口,只使用自定义函数 函数customPop(e){ //你自己的代码 控制台日志(e); } layer.bindPopup(“弹出文本”);//删除它,如果你不想弹出窗口 layer.on('contextmenu',customPop);//上下文菜单或其他事件 在本

当前的默认行为是,当弹出窗口绑定到的层被单击时,弹出窗口将打开,我想将此单击事件更改为上下文菜单事件。我正在使用layer.bindpopup函数,我看不出如何使用选项来实现这一点


您可以绑定其他处理程序,也可以不绑定弹出窗口,只使用自定义函数

函数customPop(e){
//你自己的代码
控制台日志(e);
}
layer.bindPopup(“弹出文本”);//删除它,如果你不想弹出窗口
layer.on('contextmenu',customPop);//上下文菜单或其他事件

在本例中,左键单击将打开普通弹出窗口,右键单击(上下文菜单)您自己的弹出窗口(菜单)功能。

此方法有效,但我必须使用L.Popup().openOn(地图),而不是使用layer.bindPopup。