How to use the folium.map.Popup 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 / test_map.py View on Github external
def test_popup_unicode():
    popup = Popup(u"Ça c'est chouette", parse_html=True)
    _id = list(popup.html._children.keys())[0]
    kw = {
        'id': _id,
        'width': '100.0%',
        'height': '100.0%',
        'text': u'Ça c'est chouette',
    }
    assert ''.join(popup.html.render().split()) == ''.join(tmpl(**kw).split())
github python-visualization / folium / tests / test_map.py View on Github external
def test_popup_quotes():
    popup = Popup("Let's try quotes", parse_html=True)
    _id = list(popup.html._children.keys())[0]
    kw = {
        'id': _id,
        'width': '100.0%',
        'height': '100.0%',
        'text': 'Let's try quotes',
    }
    assert ''.join(popup.html.render().split()) == ''.join(tmpl(**kw).split())
github python-visualization / folium / tests / test_map.py View on Github external
def test_popup_ascii():
    popup = Popup('Some text.')
    _id = list(popup.html._children.keys())[0]
    kw = {
        'id': _id,
        'width': '100.0%',
        'height': '100.0%',
        'text': 'Some text.',
    }
    assert ''.join(popup.html.render().split()) == ''.join(tmpl(**kw).split())
github python-visualization / folium / tests / test_map.py View on Github external
def test_popup_show():
    m = Map()
    popup = Popup('Some text.', show=True).add_to(m)
    rendered = popup._template.render(this=popup, kwargs={})
    expected = """
    var {popup_name} = L.popup({{
        "autoClose": false, "maxWidth": "100%"
    }});
    var {html_name} = $(`<div style="width: 100.0%; height: 100.0%;" id="{html_name}">Some text.</div>`)[0];
    {popup_name}.setContent({html_name});
    {map_name}.bindPopup({popup_name}).openPopup();
    """.format(popup_name=popup.get_name(),
               html_name=list(popup.html._children.keys())[0],
               map_name=m.get_name())
    # assert compare_rendered(rendered, expected)
    assert normalize(rendered) == normalize(expected)
github python-visualization / folium / tests / test_map.py View on Github external
def test_popup_sticky():
    m = Map()
    popup = Popup('Some text.', sticky=True).add_to(m)
    rendered = popup._template.render(this=popup, kwargs={})
    expected = """
    var {popup_name} = L.popup({{
        "autoClose": false, "closeOnClick": false, "maxWidth": "100%"
    }});
    var {html_name} = $(`<div style="width: 100.0%; height: 100.0%;" id="{html_name}">Some text.</div>`)[0];
    {popup_name}.setContent({html_name});
    {map_name}.bindPopup({popup_name});
    """.format(popup_name=popup.get_name(),
               html_name=list(popup.html._children.keys())[0],
               map_name=m.get_name())
    assert normalize(rendered) == normalize(expected)
github python-visualization / folium / folium / plugins / marker_cluster.py View on Github external
def __init__(self, locations=None, popups=None, icons=None, name=None,
                 overlay=True, control=True, show=True,
                 icon_create_function=None, options=None, **kwargs):
        if options is not None:
            kwargs.update(options)  # options argument is legacy
        super(MarkerCluster, self).__init__(name=name, overlay=overlay,
                                            control=control, show=show)
        self._name = 'MarkerCluster'

        if locations is not None:
            if popups is None:
                popups = [None] * len(locations)
            if icons is None:
                icons = [None] * len(locations)
            for location, popup, icon in zip(locations, popups, icons):
                p = popup if self._validate(popup, Popup) else Popup(popup)
                i = icon if self._validate(icon, Icon) else Icon(icon)
                self.add_child(Marker(location, popup=p, icon=i))

        self.options = parse_options(**kwargs)
        if icon_create_function is not None:
            assert isinstance(icon_create_function, str)
        self.icon_create_function = icon_create_function
github python-visualization / folium / folium / vector_layers.py View on Github external
def __init__(self, locations, popup=None, tooltip=None):
        super(BaseMultiLocation, self).__init__()
        self.locations = validate_locations(locations)
        if popup is not None:
            self.add_child(popup if isinstance(popup, Popup)
                           else Popup(str(popup)))
        if tooltip is not None:
            self.add_child(tooltip if isinstance(tooltip, Tooltip)
                           else Tooltip(str(tooltip)))
github python-visualization / folium / folium / map.py View on Github external
def __init__(self, location, popup=None, tooltip=None, icon=None,
                 draggable=False, **kwargs):
        super(Marker, self).__init__()
        self._name = 'Marker'
        self.location = validate_location(location)
        self.options = parse_options(
            draggable=draggable or None,
            autoPan=draggable or None,
            **kwargs
        )
        if icon is not None:
            self.add_child(icon)
        if popup is not None:
            self.add_child(popup if isinstance(popup, Popup)
                           else Popup(str(popup)))
        if tooltip is not None:
            self.add_child(tooltip if isinstance(tooltip, Tooltip)
                           else Tooltip(str(tooltip)))
github python-visualization / folium / folium / map.py View on Github external
def __init__(self, location, popup=None, tooltip=None, icon=None,
                 draggable=False, **kwargs):
        super(Marker, self).__init__()
        self._name = 'Marker'
        self.location = validate_location(location)
        self.options = parse_options(
            draggable=draggable or None,
            autoPan=draggable or None,
            **kwargs
        )
        if icon is not None:
            self.add_child(icon)
        if popup is not None:
            self.add_child(popup if isinstance(popup, Popup)
                           else Popup(str(popup)))
        if tooltip is not None:
            self.add_child(tooltip if isinstance(tooltip, Tooltip)
                           else Tooltip(str(tooltip)))