[英]Leaflet map contextmenu showing at the left top corner in the first time
我在傳單中添加了一個上下文菜單來映射。 在第一個contextmenu
事件之前, contextMenu
顯示在地圖的左上角。
let options = {
maxZoom: 20 ,
contextmenu: true,
contextmenuItems: this.mapContextMenuItems
}
this.map = L.map("map", options).setView([0, 0], 1);
您可以通過在選項中添加“位置”來操縱此菜單的位置,如下所示:
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);
添加:.leaflet-contextmenu{ display:none} 在樣式表中。 上下文菜單首先隱藏,僅出現在 'contextmenu' 事件中。 在 'contextmenu' 事件中,傳單將 'display:block' 添加到傳單上下文菜單元素,內聯。 此定義覆蓋樣式表定義。
誰能解釋為什么一開始傳單上下文菜單顯示未設置為無?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.