How to use the folium.LayerControl 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_raster_layers.py View on Github external
m = folium.Map([48., 5.], tiles='stamentoner', zoom_start=6)
    layer = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'

    folium.raster_layers.TileLayer(
        tiles=layer,
        name='OpenStreetMap',
        attr='attribution'
    ).add_to(m)

    folium.raster_layers.TileLayer(
        tiles=layer,
        name='OpenStreetMap2',
        attr='attribution2',
        overlay=True).add_to(m)

    folium.LayerControl().add_to(m)
    m._repr_html_()

    bounds = m.get_bounds()
    assert bounds == [[None, None], [None, None]], bounds
github python-visualization / folium / tests / test_folium.py View on Github external
def test_feature_group(self):
        """Test FeatureGroup."""

        m = folium.Map()
        feature_group = folium.FeatureGroup()
        feature_group.add_child(folium.Marker([45, -30],
                                              popup=folium.Popup('-30')))
        feature_group.add_child(folium.Marker([45, 30],
                                              popup=folium.Popup('30')))
        m.add_child(feature_group)
        m.add_child(folium.LayerControl())

        m._repr_html_()

        bounds = m.get_bounds()
        assert bounds == [[45, -30], [45, 30]], bounds
github bukun / book_python_gis / part010 / ch09_others / sec5_folium / test_2_data_x_x.py View on Github external
###############################################################################
ice_edge = '/gdata/folium/data/antarctic_ice_edge.json'
map_b = folium.Map(
    location=[-59.1759, -11.6016],
    tiles='Mapbox Bright',
    zoom_start=2
)
folium.GeoJson(ice_edge, name='geojson').add_to(map_b)
###############################################################################
icej='/gdata/folium/data/antarctic_ice_shelf_topo.json'
folium.TopoJson(open(icej),
    'objects.antarctic_ice_shelf',
    name='topojson'
).add_to(map_b)
###############################################################################
folium.LayerControl().add_to(map_b)
map_b.save('folium_b.html')
###############################################################################
import pandas as pd
state_geo = '/gdata/folium/data/us-states.json'
csvf = '/gdata/folium/data/US_Unemployment_Oct2012.csv'
state_data = pd.read_csv(csvf)
map_c = folium.Map(location=[48, -102], zoom_start=3)
folium.Choropleth(geo_data=state_geo,
    name='choropleth', data=state_data,
    columns=['State', 'Unemployment'], key_on='feature.id',
    fill_color='YlGn', fill_opacity=0.7, line_opacity=0.2,
    legend_name='失业率 (%)').add_to(map_c)
folium.LayerControl().add_to(map_c)
map_c.save('folium_c.html')
###############################################################################
bins = list(state_data['Unemployment'].quantile([0,0.25,0.5,0.75,1]))
github je-suis-tm / quant-trading / Oil Money project / oil production / oil production choropleth.py View on Github external
m.choropleth(
 geo_data=(open("worldmapshape.json",encoding = "utf_8_sig").read()),
 name='choropleth',
 data=df,
 columns=['Country', 'Oil Production'],
 key_on='properties.name',
 fill_color='YlOrRd',
 fill_opacity=0.7,
 line_opacity=0.2,
 legend_name='Oil Production Thousand Barrels/Day',
 threshold_scale=[0.0,1.0, 150.0, 800.0, 2000.0, 4000.0]
)

#layout control is just a map filter
#we can unselect choropleth any time
folium.LayerControl().add_to(m)
display(m)
github akkana / scripts / mapping / polidistmap.py View on Github external
# style="font-family: serif;",
                        ),
                        style_function=style_fcn,
                        highlight_function=highlight_fcn)

    # Here's how to add a popup to the whole GeoJSON object.
    # gj.add_child(folium.Popup('outline Popup on GeoJSON'))
    # But it doesn't help in adding a popup that shows the current polygon.
    # The only way seems to be to add each polygon as a separate feature:
    # https://stackoverflow.com/a/54738210
    # There may eventually be a way to do this:
    # https://github.com/python-visualization/folium/issues/802

    gj.add_to(m)

    folium.LayerControl().add_to(m)

    m.save('index.html')
    print("Saved to index.html")
github SanPen / GridCal / src / GridCal / Engine / Visualization / visualization.py View on Github external
"""

    my_map = folium.Map(location=location, zoom_start=zoom_start)

    # add possible tiles
    folium.TileLayer('cartodbpositron').add_to(my_map)
    folium.TileLayer('cartodbdark_matter').add_to(my_map)
    folium.TileLayer('openstreetmap').add_to(my_map)
    folium.TileLayer('Mapbox Bright').add_to(my_map)
    folium.TileLayer('stamentoner').add_to(my_map)

    # add markers layer
    marker_cluster = MarkerCluster().add_to(my_map)

    # add the layer control
    folium.LayerControl().add_to(my_map)

    return my_map, marker_cluster
github azavea / bus-plan / analysis / map_solver.py View on Github external
fc = [4, '#CC0000']
                else:
                    fc = [2, '#FFFFFF']
                cm = folium.CircleMarker(
                    point, color=color, fill=True,
                    fill_color=fc[1], fill_opacity=1, radius=fc[0])
                fg.add_child(cm)
            m.add_child(fg)

        lines = df.route_id.unique()
        for line in lines:
            a(df, line, pal, m)

    static_map = create_basemap(df)
    map_all(df, pal, static_map)
    folium.LayerControl().add_to(static_map)
    return static_map
github gee-community / gee_tools / geetools / ui / maptool.py View on Github external
def show(self):
        LC = folium.LayerControl()
        self.add_child(LC)
        return self