Kingwaytek

參數

mapPlus的參數說明

參數

註冊取得專屬的 Key 和 Token 後,並安裝完 mapPlus,即可使用以下程式碼,快速建立地圖。

參數說明

await new mapPlus(container, options)

地圖為非同步載入,建立地圖時,需使用 await 等待地圖載入完成。

參數:

  • container string|HTMLElement : 地圖的容器,可填選id名稱或是HTMLElement
  • options Object :
名稱描述
options.accessKey string地圖的 Key,聯絡勤崴國際團隊,取得專屬 Key。
options.accessToken string地圖的 Token,取得專屬 Key 後,於 'Get Key and Token' 頁面取得專屬的 Token。
options.style string地圖的樣式,接受.etxt格式資料。
options.center number[]地圖的初始的中心點,格式為[經度, 緯度]
options.trackResize boolean
預設: true
若為true,地圖會在瀏覽器視窗變更大小時自動調整大小。
options.zoom number
預設: 16
地圖的初始縮放級別(0-24),預設為16
options.minZoom number
預設: 7
地圖的最小縮放級別(0-24),預設為7
options.maxZoom number
預設: 16.99
地圖的最大縮放級別(0-24),預設為16.99
options.scrollZoom boolean
預設: true
若為true,將啟用「滾動縮放」互動。
options.boxZoom boolean
預設: true
若為true,將啟用「方框縮放」互動。
options.doubleClickZoom boolean
預設: true
若為true,將啟用「雙擊縮放」互動。
options.touchZoomRotate boolean
預設: true
若為true,將啟用「捏取以旋轉和縮放」互動。
options.pitch number
預設: 0
地圖的初始傾斜角(0-85),預設為0
options.minPitch number
預設: 0
地圖的最小傾斜角(0-85),預設為0
options.maxPitch number
預設: 60
地圖的最大傾斜角(0-85),預設為60
options.pitchWithRotate boolean
預設: true
若為false,使用者將無法透過「拖曳以旋轉」互動來控制地圖的傾斜角。
options.touchPitch boolean
預設: true
若為true,將啟用「拖曳以傾斜」互動。
options.bearing number
預設: 0
地圖的初始旋轉角,以度數計,預設為0
options.bearingSnap number
預設: 7
定地圖的方向(方位)在多少度內會貼齊北方。例如,若bearingSnap7,當使用者將地圖旋轉在距離北方7度以內,地圖會自動貼齊正北方向。
options.dragRotate boolean
預設: true
若為true,將啟用「拖曳以旋轉」互動。
options.dragPan boolean
預設: true
若為true,將啟用「拖曳以平移」互動。
options.keyboard boolean
預設: true
若為true,將啟用鍵盤快捷鍵。
options.interactive boolean
預設: true
若為false,地圖將不會附加滑鼠、觸控或鍵盤監聽器,因此不會對互動作出回應。
options.bounds Array null undefined
預設: undefined
地圖的初始範圍。如果指定了bounds,它將覆蓋建構選項中的centerzoom
options.maxBounds Array null undefined
預設: undefined
若設定,地圖將受限於指定的範圍內。

使用範例

基本使用:

進階使用: