簡體   English   中英

第一次在左上角顯示傳單地圖上下文菜單

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM