傳單的HTML5全屏插件。
提供一個按鈕,用於打開和關閉全屏:
// Create a new map with a fullscreen button:
var map = new L . Map ( 'map' , {
fullscreenControl : true ,
// OR
fullscreenControl : {
pseudoFullscreen : false // if true, fullscreen to page width and height
}
} ) ;
// or, add to an existing map:
map . addControl ( new L . Control . Fullscreen ( ) ) ;
該插件還向L.Map
添加了幾種方法,即使您選擇不使用全屏按鈕:
map . isFullscreen ( ) // Is the map fullscreen?
map . toggleFullscreen ( ) // Either go fullscreen, or cancel the existing fullscreen.
// `fullscreenchange` Event that's fired when entering or exiting fullscreen.
map . on ( 'fullscreenchange' , function ( ) {
if ( map . isFullscreen ( ) ) {
console . log ( 'entered fullscreen' ) ;
} else {
console . log ( 'exited fullscreen' ) ;
}
} ) ;
更改全屏控製文本:
map . addControl ( new L . Control . Fullscreen ( {
title : {
'false' : 'View Fullscreen' ,
'true' : 'Exit Fullscreen'
}
} ) ) ;
FLEFLET.FULLSCREN可通過Mapbox插件CDN獲得 - 只需複制以下內容:
< script src =' https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v1.0.1/Leaflet.fullscreen.min.js ' > </ script >
< link href =' https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v1.0.1/leaflet.fullscreen.css ' rel =' stylesheet ' />
npm install && make
Protip您可能需要安裝watch
以便您可以在每個更改上執行watch make
而無需執行。
傳單1.0及以後得到支持。較早的版本可能會起作用,但未進行測試。