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

Option to turn on/off basemap #48

Closed
wang-boyu opened this issue Apr 2, 2022 · 1 comment
Closed

Option to turn on/off basemap #48

wang-boyu opened this issue Apr 2, 2022 · 1 comment
Labels
enhancement Release notes label
Milestone

Comments

@wang-boyu
Copy link
Member

wang-boyu commented Apr 2, 2022

What's the problem this feature will solve?

Currently an OpenStreetMap layer is used as base map, but not everyone needs it as the background for visualisation. For some cases the coordinate reference system (CRS) isn't available (corrupted, missing, or the GIS data is demo files with no link to the real world), making it impossible to use a base map.

Describe the solution you'd like

In MapModule add an additional parameter to turn on/off basemap, e.g.,

map_element = MapModule(..., basemap=True, ...)

Additional context

Leaflet has many basemap providers apart from OpenStreetMap. It would be nice to have a systematic way to integrate more basemaps. Perhaps this can be raised as a separate feature request.

Then the basemap parameter can be either boolean (True/False) or string (name of the basemap provider).

Third-party libraries that might be useful: leaflet-providers (javascript), xyzservices (python)

Similar function in the lets-plot library: Configuring Basemap Tiles for Interactive Maps

@wang-boyu
Copy link
Member Author

wang-boyu commented Dec 8, 2022

It is now possible to turn off basemap by

map_element = mg.visualization.MapModule(..., tiles=None, ...)

It is also possible to define web tiles such as

map_tile = mg.RasterWebTile(
             url="https://tile.openstreetmap.org/{z}/{x}/{y}.png",
             options={
                 "attribution": "&copy; <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors"
             },
         )
map_element = mg.visualization.MapModule(..., tiles=map_tile, ...)

or use those from xyzservices:

 import xyzservices.providers as xyz

 map_element = mg.visualization.MapModule(..., tiles=xyz.CartoDB.Positron, ...)

xyzservices.providers.OpenStreetMap.Mapnik is the default tiles used.

Closing the ticket now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Release notes label
Projects
None yet
Development

No branches or pull requests

1 participant