我添加了一个上下文菜单以在传单中进行映射。在第一个contextmenu
事件之前,contextMenu
显示在地图的左上角。
let options = {
maxZoom: 20 ,
contextmenu: true,
contextmenuItems: this.mapContextMenuItems
}
this.map = L.map("map", options).setView([0, 0], 1);
答案 0 :(得分:0)
您可以通过在选项中添加“位置”来操纵此菜单的位置:
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);
答案 1 :(得分:0)
尝试在初始化后致电map.contextmenu.hide()
https://github.com/aratcliffe/Leaflet.contextmenu#methods https://github.com/aratcliffe/Leaflet.contextmenu/blob/69478afd4af9adf19ed743847cc9294e396a4d13/src/Map.ContextMenu.js#L78
答案 2 :(得分:0)
添加: .leaflet-contextmenu { 显示:无} 在样式表中。 上下文菜单首先隐藏,并且仅出现在“ contextmenu”事件中。 在'contextmenu'事件中,传单将'display:block'添加到内联的leaflet-contextmenu元素中。此定义将覆盖样式表定义。
谁能解释为什么一开始传单上下文菜单显示没有设置为无?