projectmesa / mesa-geo

GIS Extension for Mesa Agent-Based Modeling
Apache License 2.0
159 stars 54 forks source link

Option to turn on/off basemap #48

Closed wang-boyu closed 1 year ago

wang-boyu commented 2 years ago

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 commented 1 year ago

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.