Skip to content
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

Document use of multiple basemaps #971

Merged
merged 1 commit into from
Apr 20, 2022
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
23 changes: 23 additions & 0 deletions docs/source/layers/tile_layer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,32 @@ Sometimes one could want to specify the date of the given images, for instance w
nasa_layer = basemap_to_tiles(basemaps.NASAGIBS.ModisTerraTrueColorCR, "2018-04-08");
m.add_layer(nasa_layer);

.. _Tile Layer Basemap:

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``.
These layers can then be passed in an array to ``Map(layers)``:

.. jupyter-execute::

from ipyleaflet import Map, basemaps, basemap_to_tiles
from ipyleaflet import LayersControl

mapnik = basemap_to_tiles(basemaps.OpenStreetMap.Mapnik)
mapnik.base = True
toner = basemap_to_tiles(basemaps.Stamen.Toner)
toner.base = True

m = Map(layers=[mapnik, toner], center=(52.204793, 360.121558), zoom=9)

# use the LayersControl to switch basemaps
m.add_control(LayersControl())
m

Attributes and methods
----------------------

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.

.. autoclass:: ipyleaflet.leaflet.TileLayer
:members:

2 changes: 2 additions & 0 deletions docs/source/map_and_basemaps/map.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ As a Jupyter interactive widget, the layout of the ``Map`` object is specified b

m

You can use multiple basemaps my manually creating ``TileLayer`` objects and passing them to the ``Map`` constructor. (see :ref:`TileLayer Usage<Tile Layer Basemap>`)

Save to HTML
------------

Expand Down