[英]Leaflet map contextmenu showing at the left top corner in the first time
I added a context menu to map in the leaflet.我在传单中添加了一个上下文菜单来映射。 Before the first
contextmenu
event, the contextMenu
displays in the left-top corner on the map.在第一个
contextmenu
事件之前, contextMenu
显示在地图的左上角。
let options = {
maxZoom: 20 ,
contextmenu: true,
contextmenuItems: this.mapContextMenuItems
}
this.map = L.map("map", options).setView([0, 0], 1);
You can manipulate the position of this menu by adding 'position' in your options like that :您可以通过在选项中添加“位置”来操纵此菜单的位置,如下所示:
let options = {
maxZoom: 20 ,
contextmenu: true,
contextmenuItems: this.mapContextMenuItems,
// Here :
position: 'topleft', // or 'topright' or 'bottomleft' or 'bottomright'
}
this.map = L.map("map", options).setView([0, 0], 1);
Try to call map.contextmenu.hide()
after initializing初始化后尝试调用
map.contextmenu.hide()
https://github.com/aratcliffe/Leaflet.contextmenu#methods https://github.com/aratcliffe/Leaflet.contextmenu/blob/69478afd4af9adf19ed743847cc9294e396a4d13/src/Map.ContextMenu.js#L78 https://github.com/aratcliffe/Leaflet.contextmenu#methods https://github.com/aratcliffe/Leaflet.contextmenu/blob/69478afd4af9adf19ed743847cc9294e396a4d13/src/Map.ContextMenu.js#L78
add: .leaflet-contextmenu{ display:none} In the style sheet.添加:.leaflet-contextmenu{ display:none} 在样式表中。 The contextmenu hides at first, and only appears in 'contextmenu' event.
上下文菜单首先隐藏,仅出现在 'contextmenu' 事件中。 In 'contextmenu' event, leaflet add 'display:block' to the leaflet-contextmenu element, inline.
在 'contextmenu' 事件中,传单将 'display:block' 添加到传单上下文菜单元素,内联。 this definition overrides the style-sheet definition.
此定义覆盖样式表定义。
Can anyone explain why in the beginning the leaflet contextmenu display is not set to none?谁能解释为什么一开始传单上下文菜单显示未设置为无?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.