@@ -20,35 +20,30 @@ If you want to host the files yourself, you can download them from [npm](https:/
2020Add the fullscreen control to the map:
2121
2222``` js
23- let map = new L.Map (' map' , {
24- fullscreenControl: true ,
25- fullscreenControlOptions: {
26- position: ' topleft'
27- }
28- });
23+ const map = L .map (' map' );
24+
25+ map .addControl (new L.Control.FullScreen ());
2926```
3027
31- If your map has a zoomControl the fullscreen button will be added at the bottom of this one .
28+ If your map has a zoomControl, the fullscreen button will be added at the bottom of it .
3229
33- If your map doesn't have a zoomControl the fullscreen button will be added to topleft corner of the map (same as the zoomControl ).
30+ If your map doesn't have a zoomControl, the fullscreen button will be added to the topleft corner of the map (default position ).
3431
3532If you want to use the plugin on a map embedded in an iframe, don't forget to set ` allowfullscreen ` attribute on your iframe.
3633
3734** Option, events and methods** :
3835
3936``` js
4037// create a fullscreen button and add it to the map
41- L .control
42- .fullscreen ({
43- position: ' topleft' , // change the position of the button can be topleft, topright, bottomright or bottomleft, default topleft
44- title: ' Show me the fullscreen !' , // change the title of the button, default Full Screen
45- titleCancel: ' Exit fullscreen mode' , // change the title of the button when fullscreen is on, default Exit Full Screen
46- content: null , // change the content of the button, can be HTML, default null
47- forceSeparateButton: true , // force separate button to detach from zoom buttons, default false
48- forcePseudoFullscreen: true , // force use of pseudo full screen even if full screen API is available, default false
49- fullscreenElement: false // Dom element to render in full screen, false by default, fallback to map._container
50- })
51- .addTo (map);
38+ new L.Control.FullScreen ({
39+ position: ' topleft' , // change the position of the button can be topleft, topright, bottomright or bottomleft, default topleft
40+ title: ' Show me the fullscreen !' , // change the title of the button, default Full Screen
41+ titleCancel: ' Exit fullscreen mode' , // change the title of the button when fullscreen is on, default Exit Full Screen
42+ content: null , // change the content of the button, can be HTML, default null
43+ forceSeparateButton: true , // force separate button to detach from zoom buttons, default false
44+ forcePseudoFullscreen: true , // force use of pseudo full screen even if full screen API is available, default false
45+ fullscreenElement: false // Dom element to render in full screen, false by default, fallback to map._container
46+ }).addTo (map);
5247
5348// events are fired when entering or exiting fullscreen.
5449map .on (' enterFullscreen' , function () {
@@ -115,19 +110,14 @@ To use this plugin with a bundler (Webpack, Vite, etc.):
115110 <link rel =" stylesheet" href =" node_modules/leaflet.fullscreen/dist/Control.FullScreen.css" />
116111 ```
117112
118- Alternatively, you can use the classic approach with side effects :
113+ Alternatively, you can use the default export :
119114
120115``` js
121- import L from ' leaflet' ;
122- import ' leaflet.fullscreen' ;
116+ import FullScreen from ' leaflet.fullscreen' ;
123117import ' leaflet.fullscreen/dist/Control.FullScreen.css' ;
124118
125- const map = new L.Map (' map' , {
126- fullscreenControl: true ,
127- fullscreenControlOptions: {
128- position: ' topleft'
129- }
130- });
119+ const map = L .map (' map' );
120+ map .addControl (new FullScreen ());
131121```
132122
133123## Contributing
0 commit comments