Layers¶
Layer classes are available from mapwidgets and mapwidgets.layers.
VectorLayer¶
from mapwidgets import VectorLayer
layer = VectorLayer.from_shapefile("plots.shp")
Dataclass fields:
id: strdata: dict[str, Any]geometry: Literal["auto", "point", "line", "polygon"] = "auto"name: str | None = Nonefill_color: str = "#1f78ff"fill_opacity: float = 0.35stroke_color: str = "#1f78ff"stroke_opacity: float = 1.0stroke_width: int = 2circle_color: str = "#1f78ff"circle_radius: int = 5bounds: dict[str, float] | None = Noneproperties: dict[str, Any]
Methods:
VectorLayer.from_shapefile(path, **style_options)map_config()maplibre_config()google_maps_config()
RasterLayer¶
from mapwidgets import RasterLayer
layer = RasterLayer.from_geotiff(
"orthomosaic.tif",
tiles_dir="orthomosaic_tiles",
min_zoom=14,
max_zoom=22,
)
Dataclass fields:
id: strbase_url: strname: str | None = Nonemin_zoom: int = 0max_zoom: int = 22tile_size: int = 256opacity: float = 1.0cache_key: str | None = Nonebounds: dict[str, float] | None = None
Methods:
RasterLayer.from_geotiff(path, **options)RasterLayer.from_tiled_geotiff(path, **options)map_config()maplibre_config()google_maps_config()
RasterLayer.from_tiled_geotiff() accepts backend="gdal" for
osgeo_utils.gdal2tiles or backend="python" for rasterio rendering with
selected bands, colormaps, and transparency masks.