|
15 | 15 | class Fullscreen(MacroElement):
|
16 | 16 | """
|
17 | 17 | Adds a fullscreen button to your map.
|
| 18 | +
|
| 19 | + Parameters |
| 20 | + ---------- |
| 21 | + position : str |
| 22 | + change the position of the button can be: |
| 23 | + 'topleft', 'topright', 'bottomright' or 'bottomleft' |
| 24 | + defaut: 'topleft' |
| 25 | + title : str |
| 26 | + change the title of the button, |
| 27 | + default: 'Full Screen' |
| 28 | + titleCancel : str |
| 29 | + change the title of the button when fullscreen is on, |
| 30 | + default: 'Exit Full Screen' |
| 31 | + forceSeparateButton : boolean |
| 32 | + force seperate button to detach from zoom buttons, |
| 33 | + default: False |
18 | 34 | """
|
19 | 35 |
|
20 |
| - def __init__(self): |
| 36 | + def __init__(self, position='topleft', title='Full Screen', |
| 37 | + titleCancel='Exit Full Screen', forceSeparateButton=False): |
21 | 38 | """Add button to take your Folium map fullscreen"""
|
22 | 39 | super(Fullscreen, self).__init__()
|
23 | 40 | self._name = 'Fullscreen'
|
| 41 | + self.position = position |
| 42 | + self.title = title |
| 43 | + self.titleCancel = titleCancel |
| 44 | + self.forceSeparateButton = str(forceSeparateButton).lower() |
24 | 45 |
|
25 | 46 | self._template = Template("""
|
26 | 47 | {% macro script(this, kwargs) %}
|
27 |
| - L.control.fullscreen().addTo({{this._parent.get_name()}}); |
| 48 | + L.control.fullscreen({ |
| 49 | + position: '{{this.position}}', |
| 50 | + title: '{{this.title}}', |
| 51 | + titleCancel: '{{this.titleCancel}}', |
| 52 | + forceSeparateButton: {{this.forceSeparateButton}}, |
| 53 | + }).addTo({{this._parent.get_name()}}); |
28 | 54 | {{this._parent.get_name()}}.on('enterFullscreen', function(){
|
29 | 55 | console.log('entered fullscreen');
|
30 | 56 | });
|
|
0 commit comments