Skip to content

Commit e363fd4

Browse files
authored
Merge pull request #4 from python-visualization/master
2 parents 95da71e + 38e1478 commit e363fd4

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

.github/CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ The basic workflow for contributing is:
6060
git checkout -b name-of-your-branch
6161
```
6262
4. Install the dependencies listed in `requirements.txt` and `requirements-dev.txt`.
63+
```
64+
pip install -r requirements.txt
65+
pip install -r requirements-dev.txt
66+
```
6367
5. Install Firefox, download [geckodriver](https://github.com/mozilla/geckodriver/releases)
6468
and put it in the PATH.
6569
6. Make changes to your local copy of the folium repository

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ API changes
2222
Bug fixes
2323

2424
- Fix broken attribution for built-in tiles (FabeG #1128)
25+
- Fix broken prefer_canvas option of `Map` (FabeG #1133)
2526

2627
0.8.3
2728
~~~~~

folium/folium.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,14 @@ class GlobalSwitches(Element):
5555

5656
_template = Template("""
5757
<script>
58-
L_PREFER_CANVAS = {{ this.prefer_canvas|tojson }};
5958
L_NO_TOUCH = {{ this.no_touch |tojson}};
6059
L_DISABLE_3D = {{ this.disable_3d|tojson }};
6160
</script>
6261
""")
6362

64-
def __init__(self, prefer_canvas=False, no_touch=False, disable_3d=False):
63+
def __init__(self, no_touch=False, disable_3d=False):
6564
super(GlobalSwitches, self).__init__()
6665
self._name = 'GlobalSwitches'
67-
self.prefer_canvas = prefer_canvas
6866
self.no_touch = no_touch
6967
self.disable_3d = disable_3d
7068

@@ -269,11 +267,11 @@ def __init__(
269267
max_bounds=max_bounds_array,
270268
zoom=zoom_start,
271269
zoom_control=zoom_control,
270+
prefer_canvas=prefer_canvas,
272271
**kwargs
273272
)
274273

275274
self.global_switches = GlobalSwitches(
276-
prefer_canvas,
277275
no_touch,
278276
disable_3d
279277
)

tests/test_folium.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ def test_init(self):
103103
assert self.m.width == (900, 'px')
104104
assert self.m.left == (0, '%')
105105
assert self.m.top == (0, '%')
106-
assert self.m.global_switches.prefer_canvas is False
107106
assert self.m.global_switches.no_touch is False
108107
assert self.m.global_switches.disable_3d is False
109108
assert self.m.to_dict() == {
@@ -278,7 +277,7 @@ def test_fit_bounds(self):
278277
'padding': (3, 3), },
279278
sort_keys=True),
280279
'this': fitbounds,
281-
})
280+
})
282281

283282
assert ''.join(fit_bounds_rendered.split()) in ''.join(out.split())
284283

@@ -310,22 +309,30 @@ def test_custom_icon(self):
310309

311310
def test_global_switches(self):
312311
m = folium.Map(prefer_canvas=True)
313-
assert m.global_switches.prefer_canvas
312+
out = m._parent.render()
313+
out_str = ''.join(out.split())
314+
assert "preferCanvas:true" in out_str
314315
assert not m.global_switches.no_touch
315316
assert not m.global_switches.disable_3d
316317

317318
m = folium.Map(no_touch=True)
318-
assert not m.global_switches.prefer_canvas
319+
out = m._parent.render()
320+
out_str = ''.join(out.split())
321+
assert "preferCanvas:false" in out_str
319322
assert m.global_switches.no_touch
320323
assert not m.global_switches.disable_3d
321324

322325
m = folium.Map(disable_3d=True)
323-
assert not m.global_switches.prefer_canvas
326+
out = m._parent.render()
327+
out_str = ''.join(out.split())
328+
assert "preferCanvas:false" in out_str
324329
assert not m.global_switches.no_touch
325330
assert m.global_switches.disable_3d
326331

327332
m = folium.Map(prefer_canvas=True, no_touch=True, disable_3d=True)
328-
assert m.global_switches.prefer_canvas
333+
out = m._parent.render()
334+
out_str = ''.join(out.split())
335+
assert "preferCanvas:true" in out_str
329336
assert m.global_switches.no_touch
330337
assert m.global_switches.disable_3d
331338

0 commit comments

Comments
 (0)