In [1]:
import os
import folium
print(folium.__version__)
Load GeoJSON as in GeoJSON_and_choropleth.ipynb.
In [2]:
import json
import requests
url = 'https://raw.githubusercontent.com/python-visualization/folium/master/examples/data'
us_states = f'{url}/us-states.json'
geo_json_data = json.loads(requests.get(us_states).text)
In [3]:
m = folium.Map([43, -100], zoom_start=4, tiles="stamentoner")
folium.GeoJson(geo_json_data).add_to(m)
m.save(os.path.join('results', 'CustomPanes_0.html'))
m
Out[3]:
In [4]:
m = folium.Map([43, -100], zoom_start=4, tiles="stamentonerbackground")
folium.GeoJson(geo_json_data).add_to(m)
folium.map.CustomPane("labels").add_to(m)
# Final layer associated to custom pane via the appropriate kwarg
folium.TileLayer("stamentonerlabels", pane="labels").add_to(m)
m.save(os.path.join('results', 'CustomPanes_1.html'))
m
Out[4]:
In [5]:
m = folium.Map([43, -100], zoom_start=4, tiles="CartoDBPositronNoLabels")
folium.GeoJson(geo_json_data).add_to(m)
folium.map.CustomPane("labels").add_to(m)
# Final layer associated to custom pane via the appropriate kwarg
folium.TileLayer("CartoDBPositronOnlyLabels", pane="labels").add_to(m)
m.save(os.path.join('results', 'CustomPanes_2.html'))
m
Out[5]:
More tile providers can be found at https://leaflet-extras.github.io/leaflet-providers/preview/.