How to use the folium.utilities.normalize function in folium

To help you get started, we’ve selected a few folium examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python-visualization / folium / tests / plugins / test_scroll_zoom_toggler.py View on Github external
tmpl = Template("""
        <style>
            #{{this.get_name()}} {
                position:absolute;
                width:35px;
                bottom:10px;
                height:35px;
                left:10px;
                background-color:#fff;
                text-align:center;
                line-height:35px;
                vertical-align: middle;
                }
        </style>
    """)
    expected = normalize(tmpl.render(this=szt))
    assert expected in out

    # Verify that the script is okay.
    tmpl = Template("""
        {{this._parent.get_name()}}.scrollEnabled = true;

        {{this._parent.get_name()}}.toggleScroll = function() {
            if (this.scrollEnabled) {
                this.scrollEnabled = false;
                this.scrollWheelZoom.disable();
            } else {
                this.scrollEnabled = true;
                this.scrollWheelZoom.enable();
            }
        };
github python-visualization / folium / tests / plugins / test_dual_map.py View on Github external
folium.FeatureGroup(name='left').add_to(m.m1)
    folium.FeatureGroup(name='right').add_to(m.m2)

    figure = m.get_root()
    assert isinstance(figure, folium.Figure)
    out = normalize(figure.render())

    script = ''  # noqa
    assert script in out

    tmpl = Template("""
        {{ this.m1.get_name() }}.sync({{ this.m2.get_name() }});
        {{ this.m2.get_name() }}.sync({{ this.m1.get_name() }});
    """)

    assert normalize(tmpl.render(this=m)) in out
github python-visualization / folium / tests / plugins / test_float_image.py View on Github external
style="z-index: 999999"&gt;
        
    """)
    assert normalize(tmpl.render(this=szt)) in out

    # Verify that the style has been created.
    tmpl = Template("""
        <style>
            #{{this.get_name()}} {
                position:absolute;
                bottom:60%;
                left:70%;
                }
        </style>
    """)
    assert normalize(tmpl.render(this=szt)) in out

    bounds = m.get_bounds()
    assert bounds == [[None, None], [None, None]], bounds
github python-visualization / folium / tests / test_vector_layers.py View on Github external
"fillOpacity": 0.2,
    "fillRule": "evenodd",
    "lineCap": "round",
    "lineJoin": "round",
    "noClip": false,
    "opacity": 1.0,
    "smoothFactor": 1.0,
    "stroke": true,
    "weight": 3
    }}
    )
    .addTo({map});
    """.format(locations=locations, name=polygon.get_name(), map=m.get_name())

    rendered = polygon._template.module.script(polygon)
    assert normalize(rendered) == normalize(expected_rendered)
    assert polygon.get_bounds() == get_bounds(locations)
    assert json.dumps(polygon.to_dict()) == polygon.to_json()
    assert polygon.options == expected_options
github python-visualization / folium / tests / test_map.py View on Github external
def test_custom_pane_show():
    m = Map()
    pane = CustomPane('test-name', z_index=625, pointer_events=False).add_to(m)
    rendered = pane._template.module.script(this=pane, kwargs={})
    expected = """
    var {pane_name} = {map_name}.createPane("test-name");
    {pane_name}.style.zIndex = 625;
    {pane_name}.style.pointerEvents = 'none';
    """.format(pane_name=pane.get_name(),
               map_name=m.get_name())
    assert normalize(rendered) == normalize(expected)
github python-visualization / folium / tests / test_raster_layers.py View on Github external
# Verify the URL generation.
    url = ('data:image/png;base64,'
           'iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAA'
           'AF0lEQVR42mP4z8AARFDw/z/DeiA5H4QBV60H6ABl9ZIAAAAASUVORK5CYII=')
    assert io.url == url

    # Verify the script part is okay.
    tmpl = Template("""
        var {{this.get_name()}} = L.imageOverlay(
            "{{ this.url }}",
            {{ this.bounds }},
            {{ this.options }}
            ).addTo({{this._parent.get_name()}});
    """)
    assert normalize(tmpl.render(this=io)) in normalize(out)

    bounds = m.get_bounds()
    assert bounds == [[0, -180], [90, 180]], bounds
github python-visualization / folium / tests / test_vector_layers.py View on Github external
"fillColor": "black",
    "fillOpacity": 0.6,
    "fillRule": "evenodd",
    "lineCap": "round",
    "lineJoin": "round",
    "opacity": 1,
    "radius": {radius},
    "stroke": true,
    "weight": 2
    }}
    )
    .addTo({map});
    """.format(name=circle.get_name(), location=location, radius=radius, map=m.get_name())  # noqa

    rendered = circle._template.module.script(circle)
    assert normalize(rendered) == normalize(expected_rendered)
    assert circle.get_bounds() == [location, location]
    assert json.dumps(circle.to_dict()) == circle.to_json()
    assert circle.location == [-27.551667, -48.478889]
    assert circle.options == expected_options
github python-visualization / folium / tests / plugins / test_antpath.py View on Github external
# We verify that the script import is present.
    script = ''  # noqa
    assert script in out

    # We verify that the script part is correct.
    tmpl = Template("""
          {{this.get_name()}} = L.polyline.antPath(
                  {{ this.location|tojson }},
                  {{ this.options|tojson }}
                )
                .addTo({{this._parent.get_name()}});
        """)  # noqa

    expected_rendered = tmpl.render(this=antpath)
    rendered = antpath._template.module.script(antpath)
    assert normalize(expected_rendered) == normalize(rendered)
github python-visualization / folium / tests / test_vector_layers.py View on Github external
"fillColor": "black",
    "fillOpacity": 0.6,
    "fillRule": "evenodd",
    "lineCap": "round",
    "lineJoin": "round",
    "opacity": 1,
    "radius": {radius},
    "stroke": true,
    "weight": 2
    }}
    )
    .addTo({map});
    """.format(name=circle_marker.get_name(), location=location, radius=radius, map=m.get_name())  # noqa

    rendered = circle_marker._template.module.script(circle_marker)
    assert normalize(rendered) == normalize(expected_rendered)
    assert circle_marker.get_bounds() == expected_bounds
    assert json.dumps(circle_marker.to_dict()) == circle_marker.to_json()
    assert circle_marker.location == location
    assert circle_marker.options == options
github python-visualization / folium / tests / test_vector_layers.py View on Github external
"fillOpacity": 0.6,
    "fillRule": "evenodd",
    "lineCap": "round",
    "lineJoin": "round",
    "noClip": false,
    "opacity": 1,
    "smoothFactor": 1.0,
    "stroke": true,
    "weight": 2
    }}
    )
    .addTo({map});
    """.format(name=rectangle.get_name(), location=location, map=m.get_name())

    rendered = rectangle._template.module.script(rectangle)
    assert normalize(rendered) == normalize(expected_rendered)
    assert rectangle.get_bounds() == location
    assert json.dumps(rectangle.to_dict()) == rectangle.to_json()
    assert rectangle.options == expected_options