Skip to content

Remove deprecated tilesets #1339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions folium/folium.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,20 +150,16 @@ class Map(MacroElement):

Examples
--------
>>> m = folium.Map(location=[45.523, -122.675],
... width=750, height=500)
>>> m = folium.Map(location=[45.523, -122.675],
tiles='Mapbox Control Room')
>>> m = folium.Map(location=(45.523, -122.675), max_zoom=20,
tiles='Cloudmade', API_key='YourKey')
>>> m = folium.Map(location=[45.523, -122.675], width=750, height=500)
>>> m = folium.Map(location=[45.523, -122.675], tiles='cartodb positron')
>>> m = folium.Map(
... location=[45.523, -122.675],
... zoom_start=2,
... tiles='http://{s}.tiles.mapbox.com/v3/mapbox.control-room/{z}/{x}/{y}.png',
... tiles='https://api.mapbox.com/v4/mapbox.streets/{z}/{x}/{y}.png?access_token=mytoken',
... attr='Mapbox attribution'
...)

"""
""" # noqa
_template = Template(u"""
{% macro header(this, kwargs) %}
<meta name="viewport" content="width=device-width,
Expand Down
19 changes: 9 additions & 10 deletions folium/raster_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ class TileLayer(Layer):
- "OpenStreetMap"
- "Stamen Terrain", "Stamen Toner", "Stamen Watercolor"
- "CartoDB positron", "CartoDB dark_matter"
- "Mapbox Bright", "Mapbox Control Room" (Limited zoom)
- "Cloudmade" (Must pass API key)
- "Mapbox" (Must pass API key)

You can pass a custom tileset to Folium by passing a Leaflet-style
URL to the tiles parameter: ``http://{s}.yourtiles.com/{z}/{x}/{y}.png``.
Expand All @@ -47,8 +44,6 @@ class TileLayer(Layer):
If provided you can zoom in past this level. Else tiles will turn grey.
attr: string, default None
Map tile attribution; only required if passing custom tile URL.
API_key: str, default None
API key for Cloudmade or Mapbox tiles.
detect_retina: bool, default False
If true and user is on a retina display, it will request four
tiles of half the specified size and a bigger zoom level in place
Expand Down Expand Up @@ -82,7 +77,7 @@ class TileLayer(Layer):
""")

def __init__(self, tiles='OpenStreetMap', min_zoom=0, max_zoom=18,
max_native_zoom=None, attr=None, API_key=None,
max_native_zoom=None, attr=None,
detect_retina=False, name=None, overlay=False,
control=True, show=True, no_wrap=False, subdomains='abc',
tms=False, opacity=1, **kwargs):
Expand All @@ -95,16 +90,20 @@ def __init__(self, tiles='OpenStreetMap', min_zoom=0, max_zoom=18,
self._env = ENV

tiles_flat = ''.join(tiles.lower().strip().split())
if tiles_flat in ('cloudmade', 'mapbox') and not API_key:
raise ValueError('You must pass an API key if using Cloudmade'
' or non-default Mapbox tiles.')
if tiles_flat in {'cloudmade', 'mapbox', 'mapboxbright', 'mapboxcontrolroom'}:
# added in May 2020 after v0.11.0, remove in a future release
raise ValueError(
'Built-in templates for Mapbox and Cloudmade have been removed. '
'You can still use these providers by passing a URL to the `tiles` '
'argument. See the documentation of the `TileLayer` class.'
)
templates = list(self._env.list_templates(
filter_func=lambda x: x.startswith('tiles/')))
tile_template = 'tiles/' + tiles_flat + '/tiles.txt'
attr_template = 'tiles/' + tiles_flat + '/attr.txt'

if tile_template in templates and attr_template in templates:
self.tiles = self._env.get_template(tile_template).render(API_key=API_key) # noqa
self.tiles = self._env.get_template(tile_template).render()
attr = self._env.get_template(attr_template).render()
else:
self.tiles = tiles
Expand Down
1 change: 0 additions & 1 deletion folium/templates/tiles/cloudmade/attr.txt

This file was deleted.

1 change: 0 additions & 1 deletion folium/templates/tiles/cloudmade/tiles.txt

This file was deleted.

1 change: 0 additions & 1 deletion folium/templates/tiles/mapbox/attr.txt

This file was deleted.

1 change: 0 additions & 1 deletion folium/templates/tiles/mapbox/tiles.txt

This file was deleted.

1 change: 0 additions & 1 deletion folium/templates/tiles/mapboxbright/attr.txt

This file was deleted.

1 change: 0 additions & 1 deletion folium/templates/tiles/mapboxbright/tiles.txt

This file was deleted.

1 change: 0 additions & 1 deletion folium/templates/tiles/mapboxcontrolroom/attr.txt

This file was deleted.

1 change: 0 additions & 1 deletion folium/templates/tiles/mapboxcontrolroom/tiles.txt

This file was deleted.

2 changes: 0 additions & 2 deletions tests/test_folium.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ def test_builtin_tile(self):
"OpenStreetMap",
"Stamen Terrain",
"Stamen Toner",
"Mapbox Bright",
"Mapbox Control Room",
"CartoDB positron",
"CartoDB dark_matter",
]
Expand Down
10 changes: 0 additions & 10 deletions tests/test_raster_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,6 @@ def test_custom_tile_subdomains():
assert 'mytilesubdomain' in out


def test_tilelayer_api_key():
"""Test cloudmade tiles and the API key."""
with pytest.raises(ValueError):
folium.TileLayer(tiles='cloudmade')

tile_layer = folium.TileLayer(tiles='cloudmade', API_key='###')
cloudmade = 'http://{s}.tile.cloudmade.com/###/997/256/{z}/{x}/{y}.png'
assert tile_layer.tiles == cloudmade


def test_wms():
m = folium.Map([40, -100], zoom_start=4)
url = 'http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi'
Expand Down