传单的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及以后得到支持。较早的版本可能会起作用,但未进行测试。