Skip to content

Commit

Permalink
cleanup fit_bounds.js template (#1920)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conengmo authored Apr 4, 2024
1 parent e6c5779 commit 290252f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
11 changes: 0 additions & 11 deletions folium/templates/fit_bounds.js

This file was deleted.

24 changes: 18 additions & 6 deletions tests/test_folium.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import pandas as pd
import pytest
import xyzservices.providers as xyz
from jinja2 import Environment, PackageLoader
from jinja2 import Template
from jinja2.utils import htmlsafe_json_dumps

import folium
Expand Down Expand Up @@ -69,7 +69,21 @@ def setup_method(self):
font_size="1.5rem",
attr=attr,
)
self.env = Environment(loader=PackageLoader("folium", "templates"))
self.fit_bounds_template = Template(
"""
{% if autobounds %}
var autobounds = L.featureGroup({{ features }}).getBounds()
{% if not bounds %}
{% set bounds = "autobounds" %}
{% endif %}
{% endif %}
{% if bounds %}
{{this._parent.get_name()}}.fitBounds({{ bounds }},
{{ fit_bounds_options }}
);
{% endif %}
"""
)

def test_init(self):
"""Test map initialization."""
Expand Down Expand Up @@ -385,8 +399,7 @@ def test_fit_bounds(self):
][0]
out = self.m._parent.render()

fit_bounds_tpl = self.env.get_template("fit_bounds.js")
fit_bounds_rendered = fit_bounds_tpl.render(
fit_bounds_rendered = self.fit_bounds_template.render(
{
"bounds": json.dumps(bounds),
"this": fitbounds,
Expand All @@ -406,8 +419,7 @@ def test_fit_bounds_2(self):
][0]
out = self.m._parent.render()

fit_bounds_tpl = self.env.get_template("fit_bounds.js")
fit_bounds_rendered = fit_bounds_tpl.render(
fit_bounds_rendered = self.fit_bounds_template.render(
{
"bounds": json.dumps(bounds),
"fit_bounds_options": json.dumps(
Expand Down

0 comments on commit 290252f

Please sign in to comment.