How to use branca - 10 common examples

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 python-visualization / folium / folium / plugins / image_overlay.py View on Github external
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 BibMartin / crossfolium / tests / test_marker_function.py View on Github external
def test_no_marker_function():
    f = branca.element.Figure()
    c = crossfolium.Crossfilter([{'lat': 0, 'lng': 0}]).add_to(f)
    m = folium.Map().add_to(c)
    crossfolium.FeatureGroupFilter(c).add_to(m)

    out = ''.join(f.render().split())
    tmp = ''.join("""
        .marker_function = function(d) {
            return L.marker([0, 0]);}
        """.split())
    assert tmp in out
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 / tests / test_features.py View on Github external
def test_divicon():
    html = """<svg width="100" height="100">
              <circle fill="red" stroke-width="3" stroke="black" r="40" cy="50" cx="50"></circle>
              </svg>"""  # noqa
    div = folium.DivIcon(html=html)
    assert isinstance(div, Element)
    assert div.options['className'] == 'empty'
    assert div.options['html'] == html
github python-visualization / folium / tests / test_features.py View on Github external
def test_figure_creation():
    f = folium.Figure()
    assert isinstance(f, Element)

    bounds = f.get_bounds()
    assert bounds == [[None, None], [None, None]], bounds
github python-visualization / branca / tests / test_colormap.py View on Github external
def test_simple_linear():
    linear = cm.LinearColormap(['green', 'yellow', 'red'], vmin=3., vmax=10.)
    linear = cm.LinearColormap(['red', 'orange', 'yellow', 'green'],
                               index=[0, 0.1, 0.9, 1.])
    linear._repr_html_()
github python-visualization / branca / tests / test_colormap.py View on Github external
def test_step_to_linear():
    step = cm.StepColormap(['green', 'yellow', 'red'],
                           vmin=3., vmax=10.,
                           index=[3, 4, 8, 10], caption='step')
    step.to_linear()
github python-visualization / branca / tests / test_colormap.py View on Github external
def test_simple_step():
    step = cm.StepColormap(['green', 'yellow', 'red'],
                           vmin=3., vmax=10.,
                           index=[3, 4, 8, 10], caption='step')
    step = cm.StepColormap(['r', 'y', 'g', 'c', 'b', 'm'])
    step._repr_html_()