How to use the branca.element.Figure function in branca

To help you get started, we’ve selected a few branca 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 / folium / plugins / image_overlay.py View on Github external
def render(self, **kwargs):
        super(ImageOverlay, self).render()

        figure = self.get_root()
        assert isinstance(figure, Figure), ('You cannot render this Element '
                                            'if it is not in a Figure.')
        pixelated = """<style>
        .leaflet-image-layer {
        image-rendering: -webkit-optimize-contrast; /* old android/safari*/
        image-rendering: crisp-edges; /* safari */
        image-rendering: pixelated; /* chrome */
        image-rendering: -moz-crisp-edges; /* firefox */
        image-rendering: -o-crisp-edges; /* opera */
        -ms-interpolation-mode: nearest-neighbor; /* ie */
        }
        </style>"""

        if self.pixelated:
            figure.header.add_child(Element(pixelated), name='leaflet-image-layer')  # noqa
github BibMartin / crossfolium / tests / test_marker_function.py View on Github external
def test_marker_function():
    f = branca.element.Figure()
    c = crossfolium.Crossfilter([{'lat': 0, 'lng': 0}]).add_to(f)
    m = folium.Map().add_to(c)
    g = crossfolium.FeatureGroupFilter(c).add_to(m)
    crossfolium.marker_function.MarkerFunction(
        lat='Latitude',
        lng='Longitude',
        popup='Popup',
        ).add_to(g)

    out = ''.join(f.render().split())
    tmp = ''.join("""
        .marker_function = function (d) {
            return L.marker([d["Latitude"], d["Longitude"]])
                .bindPopup(d["Popup"]);
            }
        """.split())
github python-visualization / branca / tests / test_iframe.py View on Github external
def test_rendering_figure_notebook():
    """Verify special characters are correctly rendered in Jupyter notebooks."""
    text = '5/7 %, Линейная улица, "\u00e9 Berdsk"'
    figure = elem.Figure()
    elem.Html(text).add_to(figure.html)
    html = figure._repr_html_()

    filepath = 'temp_test_rendering_figure_notebook.html'
    filepath = os.path.abspath(filepath)
    with open(filepath, 'w') as f:
        f.write(html)

    options = Options()
    options.add_argument('-headless')
    driver = Firefox(options=options)
    try:
        driver.get('file://' + filepath)
        driver.switch_to.frame(0)
        text_div = driver.find_element_by_css_selector('div')
        assert text_div.text == text
github python-visualization / folium / folium / plugins / minimap.py View on Github external
def render(self, **kwargs):
        figure = self.get_root()
        assert isinstance(figure, Figure), ('You cannot render this Element '
                                            'if it is not in a Figure.')
        super(MiniMap, self).render()

        figure.header.add_child(JavascriptLink('https://cdnjs.cloudflare.com/ajax/libs/leaflet-minimap/3.6.1/Control.MiniMap.js'))  # noqa

        figure.header.add_child(CssLink('https://cdnjs.cloudflare.com/ajax/libs/leaflet-minimap/3.6.1/Control.MiniMap.css'))  # noqa
github python-visualization / branca / branca / element.py View on Github external
def render(self, **kwargs):
        """Renders the HTML representation of the element."""
        figure = self.get_root()
        assert isinstance(figure, Figure), ('You cannot render this Element '
                                            'if it is not in a Figure.')

        header = self._template.module.__dict__.get('header', None)
        if header is not None:
            figure.header.add_child(Element(header(self, kwargs)),
                                    name=self.get_name())

        html = self._template.module.__dict__.get('html', None)
        if html is not None:
            figure.html.add_child(Element(html(self, kwargs)),
                                  name=self.get_name())

        script = self._template.module.__dict__.get('script', None)
        if script is not None:
            figure.script.add_child(Element(script(self, kwargs)),
                                    name=self.get_name())
github python-visualization / folium / folium / plugins / dual_map.py View on Github external
assert key not in kwargs, ('Argument {} cannot be used with '
                                       'DualMap.'.format(key))
        if layout not in ('horizontal', 'vertical'):
            raise ValueError('Undefined option for argument `layout`: {}. '
                             'Use either \'horizontal\' or \'vertical\'.'
                             .format(layout))
        width = '50%' if layout == 'horizontal' else '100%'
        height = '100%' if layout == 'horizontal' else '50%'
        self.m1 = Map(location=location, width=width, height=height,
                      left='0%', top='0%',
                      position='absolute', **kwargs)
        self.m2 = Map(location=location, width=width, height=height,
                      left='50%' if layout == 'horizontal' else '0%',
                      top='0%' if layout == 'horizontal' else '50%',
                      position='absolute', **kwargs)
        figure = Figure()
        figure.add_child(self.m1)
        figure.add_child(self.m2)
        # Important: add self to Figure last.
        figure.add_child(self)
        self.children_for_m2 = []
        self.children_for_m2_copied = []  # list with ids
github python-visualization / folium / folium / plugins / measure_control.py View on Github external
def render(self, **kwargs):
        super(MeasureControl, self).render()

        figure = self.get_root()
        assert isinstance(figure, Figure), ('You cannot render this Element '
                                            'if it is not in a Figure.')

        figure.header.add_child(
            JavascriptLink('https://rawcdn.githack.com/ljagis/leaflet-measure/2.1.7/dist/leaflet-measure.js'))  # noqa

        figure.header.add_child(
            CssLink('https://rawcdn.githack.com/ljagis/leaflet-measure/2.1.7/dist/leaflet-measure.css'))  # noqa
github python-visualization / folium / folium / features.py View on Github external
def render(self, **kwargs):
        """Renders the HTML representation of the element."""
        super(RegularPolygonMarker, self).render()

        figure = self.get_root()
        assert isinstance(figure, Figure), ('You cannot render this Element '
                                            'if it is not in a Figure.')

        figure.header.add_child(
            JavascriptLink('https://cdnjs.cloudflare.com/ajax/libs/leaflet-dvf/0.3.0/leaflet-dvf.markers.min.js'),
            # noqa
            name='dvf_js')
github python-visualization / folium / folium / plugins / fullscreen.py View on Github external
def render(self, **kwargs):
        super(Fullscreen, self).render()

        figure = self.get_root()
        assert isinstance(figure, Figure), ('You cannot render this Element '
                                            'if it is not in a Figure.')

        figure.header.add_child(
            JavascriptLink('https://cdnjs.cloudflare.com/ajax/libs/leaflet.fullscreen/1.4.2/Control.FullScreen.min.js'),  # noqa
            name='Control.Fullscreen.js'
        )

        figure.header.add_child(
            CssLink('https://cdnjs.cloudflare.com/ajax/libs/leaflet.fullscreen/1.4.2/Control.FullScreen.min.css'),  # noqa
            name='Control.FullScreen.css'
        )