Пример #1
0
 def test_boat_marker(self):
     mapa = folium.Map([30., 0.], zoom_start=3)
     mapa.add_children(plugins.BoatMarker((34, -43),
                                          heading=45,
                                          wind_heading=150,
                                          wind_speed=45,
                                          color="#8f8"))
     mapa.add_children(plugins.BoatMarker((46, -30),
                                          heading=-20,
                                          wind_heading=46,
                                          wind_speed=25,
                                          color="#88f"))
     mapa._repr_html_()
Пример #2
0
def test_boat_marker():
    m = folium.Map([30., 0.], zoom_start=3)
    bm1 = plugins.BoatMarker((34, -43),
                             heading=45,
                             wind_heading=150,
                             wind_speed=45,
                             color='#8f8')
    bm2 = plugins.BoatMarker((46, -30),
                             heading=-20,
                             wind_heading=46,
                             wind_speed=25,
                             color='#88f')

    m.add_child(bm1)
    m.add_child(bm2)
    m._repr_html_()

    out = normalize(m._parent.render())

    # We verify that the script import is present.
    script = '<script src="https://unpkg.com/leaflet.boatmarker/leaflet.boatmarker.min.js"></script>'  # noqa
    assert script in out

    # We verify that the script part is correct.
    tmpl = Template(u"""
        var {{ this.get_name() }} = L.boatMarker(
            {{ this.location|tojson }},
            {{ this.options|tojson }}
        ).addTo({{ this._parent.get_name() }});
        {{ this.get_name() }}.setHeadingWind(
            {{ this.heading }},
            {{ this.wind_speed }},
            {{ this.wind_heading }}
        );
    """)

    assert normalize(tmpl.render(this=bm1)) in out
    assert normalize(tmpl.render(this=bm2)) in out

    bounds = m.get_bounds()
    assert bounds == [[34, -43], [46, -30]], bounds
Пример #3
0
def test_boat_marker():
    m = folium.Map([30., 0.], zoom_start=3)
    bm1 = plugins.BoatMarker((34, -43),
                             heading=45,
                             wind_heading=150,
                             wind_speed=45,
                             color="#8f8")
    bm2 = plugins.BoatMarker((46, -30),
                             heading=-20,
                             wind_heading=46,
                             wind_speed=25,
                             color="#88f")

    m.add_children(bm1)
    m.add_children(bm2)
    m._repr_html_()

    out = m._parent.render()

    # We verify that the script import is present
    assert (
        '<script src="https://thomasbrueggemann.github.io/leaflet.boatmarker/'
        'js/leaflet.boatmarker.min.js"></script>') in out

    # We verify that the script part is correct
    tmpl = Template("""
                var {{this.get_name()}} = L.boatMarker(
                    [{{this.location[0]}},{{this.location[1]}}],
                    {{this.kwargs}}).addTo({{this._parent.get_name()}});
                {{this.get_name()}}.setHeadingWind({{this.heading}}, {{this.wind_speed}}, {{this.wind_heading}});
    """)

    assert tmpl.render(this=bm1) in out
    assert tmpl.render(this=bm2) in out

    bounds = m.get_bounds()
    assert bounds == [[34, -43], [46, -30]], bounds
Пример #4
0
def test_boat_marker_with_no_wind_speed_or_heading():
    m = folium.Map([30., 0.], zoom_start=3)
    bm1 = plugins.BoatMarker((34, -43), heading=45, color='#8f8')
    m.add_child(bm1)

    out = m._parent.render()

    # We verify that the script part is correct.
    tmpl = Template("""
                var {{this.get_name()}} = L.boatMarker(
                    [{{this.location[0]}},{{this.location[1]}}],
                    {{this.kwargs}}).addTo({{this._parent.get_name()}});
                {{this.get_name()}}.setHeading({{this.heading}});
    """)  # noqa

    assert tmpl.render(this=bm1) in out
Пример #5
0
def test_boat_marker_with_no_wind_speed_or_heading():
    m = folium.Map([30., 0.], zoom_start=3)
    bm1 = plugins.BoatMarker((34, -43), heading=45, color='#8f8')
    m.add_child(bm1)

    out = normalize(m._parent.render())

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

    assert normalize(tmpl.render(this=bm1)) in out