Skip to content

Commit e9f4bf9

Browse files
committed
Document use of multiple basemaps
1 parent 04c734c commit e9f4bf9

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

docs/source/layers/tile_layer.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,32 @@ Sometimes one could want to specify the date of the given images, for instance w
3131
nasa_layer = basemap_to_tiles(basemaps.NASAGIBS.ModisTerraTrueColorCR, "2018-04-08");
3232
m.add_layer(nasa_layer);
3333
34+
.. _Tile Layer Basemap:
35+
36+
To use multiple base maps and the built in base map switching in ``LayerControl``, it is possible to create the desired ``TileLayer`` objects and set ``base`` to ``True``.
37+
These layers can then be passed in an array to ``Map(layers)``:
38+
39+
.. jupyter-execute::
40+
41+
from ipyleaflet import Map, basemaps, basemap_to_tiles
42+
from ipyleaflet import LayersControl
43+
44+
mapnik = basemap_to_tiles(basemaps.OpenStreetMap.Mapnik)
45+
mapnik.base = True
46+
toner = basemap_to_tiles(basemaps.Stamen.Toner)
47+
toner.base = True
48+
49+
m = Map(layers=[mapnik, toner], center=(52.204793, 360.121558), zoom=9)
50+
51+
# use the LayersControl to switch basemaps
52+
m.add_control(LayersControl())
53+
m
54+
3455
Attributes and methods
3556
----------------------
57+
3658
Note that if you want to display a high resolution layer with a quite large zoom, you have to set ``max_zoom`` and ``max_native_zoom`` with equal value.
59+
3760
.. autoclass:: ipyleaflet.leaflet.TileLayer
3861
:members:
3962

docs/source/map_and_basemaps/map.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ As a Jupyter interactive widget, the layout of the ``Map`` object is specified b
5454

5555
m
5656

57+
You can use multiple basemaps my manually creating ``TileLayer`` objects and passing them to the ``Map`` constructor. (see :ref:`TileLayer Usage<Tile Layer Basemap>`)
58+
5759
Save to HTML
5860
------------
5961

0 commit comments

Comments
 (0)