config
config
Style configuration dataclasses for Mapyta.
Classes:
-
CircleStyle–Style for circle markers (fixed pixel size).
-
ClusterStyle–Grouping of nearby markers into one clickable bubble.
-
DrawConfig–Configuration for Leaflet.draw drawing controls.
-
FillStyle–Style for polygon fills.
-
HeatmapStyle–Configuration for heatmap layers.
-
MapConfig–Global map configuration.
-
PopupStyle–Popup appearance configuration.
-
RawJS–Marker for raw JavaScript that should not be escaped.
-
StrokeStyle–Style for lines and polygon borders.
-
TooltipStyle–Tooltip appearance configuration.
config.DrawTool
module-attribute
DrawTool = Literal['marker', 'polyline', 'polygon', 'rectangle', 'circle']
Valid drawing tool names for :meth:~mapyta.map.Map.enable_draw.
config.CircleStyle
dataclass
CircleStyle(
radius: float = 8.0,
stroke: StrokeStyle = StrokeStyle(),
fill: FillStyle = FillStyle(),
)
Style for circle markers (fixed pixel size).
Parameters:
-
radius(float, default:8.0) –Circle radius in pixels.
-
stroke(StrokeStyle, default:StrokeStyle()) –Border stroke style.
-
fill(FillStyle, default:FillStyle()) –Fill style.
config.ClusterStyle
dataclass
ClusterStyle(
disable_at_zoom: int | None = None,
max_radius: int = 80,
spiderfy: bool = True,
icon_create_js: str | None = None,
)
Grouping of nearby markers into one clickable bubble.
Leaflet keeps every marker of a layer in the DOM and repositions all of them on each zoom, so a layer running into the thousands blocks the browser for the length of the gesture. Clustering leaves only the markers of the current view in the DOM, which is what keeps such a layer interactive.
Parameters:
-
disable_at_zoom(int | None, default:None) –Zoom level from which every marker is drawn on its own again.
Noneclusters at every zoom, down to the pair that happens to overlap. -
max_radius(int, default:80) –How far apart, in pixels on screen, two markers may be and still share a bubble.
-
spiderfy(bool, default:True) –Whether clicking a bubble that cannot be split by zooming any further fans its markers out around it.
-
icon_create_js(str | None, default:None) –JavaScript function expression building the bubble icon, receiving the cluster and returning an
L.divIcon.Nonegives Leaflet.markercluster's own green-amber-red bubbles, whose colour reads as a count — pass a function of your own when the map already spends those colours on a meaning of its own.
config.ClusterStyle.leaflet_options
leaflet_options() -> dict[str, Any]
Return the Leaflet.markercluster options this style stands for.
Returns:
-
dict[str, Any]–Options for
L.markerClusterGroup.
Source code in mapyta/config.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
config.DrawConfig
dataclass
DrawConfig(
tools: list[DrawTool] = (lambda: ["polyline", "polygon", "marker"])(),
on_submit: str | RawJS | None = None,
position: str = "topleft",
submit_label: str = "Submit",
draw_style: dict[str, Any] | None = None,
edit: bool = True,
delete_confirm_message: str = "Delete this shape?",
delete_confirm_yes: str = "Delete",
delete_confirm_no: str = "Cancel",
)
Configuration for Leaflet.draw drawing controls.
Parameters:
-
tools(list[DrawTool], default:(lambda: ['polyline', 'polygon', 'marker'])()) –Active drawing tools:
"marker","polyline","polygon","rectangle","circle". -
on_submit(str | RawJS | None, default:None) –Callback on submit.
None= download, URL = fetch, string = function name,RawJS= inline JS. -
position(str, default:'topleft') –Toolbar position.
-
submit_label(str, default:'Submit') –Submit button text.
-
draw_style(dict[str, Any] | None, default:None) –shapeOptionsoverride for drawn shapes. -
edit(bool, default:True) –Whether per-shape editing/deletion is active. When
True, clicking a drawn shape makes its vertices editable in place (click empty map space to stop editing) and shows a trashbin at its last vertex; clicking the trashbin and confirming deletes that shape. No global edit/delete toolbar buttons are rendered. WhenFalse, clicking a shape stays inert. -
delete_confirm_message(str, default:'Delete this shape?') –Text shown in the in-map deletion confirmation popup.
-
delete_confirm_yes(str, default:'Delete') –Label of the confirm (delete) button in that popup.
-
delete_confirm_no(str, default:'Cancel') –Label of the cancel button in that popup.
config.FillStyle
dataclass
FillStyle(color: str = '#3388ff', opacity: float = 0.2)
Style for polygon fills.
Parameters:
-
color(str, default:'#3388ff') –Fill CSS color.
-
opacity(float, default:0.2) –Fill opacity, 0.0 - 1.0.
config.HeatmapStyle
dataclass
HeatmapStyle(
radius: int = 15,
blur: int = 10,
min_opacity: float = 0.3,
max_zoom: int = 18,
gradient: dict[float, str] | None = None,
)
Configuration for heatmap layers.
Parameters:
-
radius(int, default:15) –Radius of each location in pixels.
-
blur(int, default:10) –Blur radius in pixels.
-
min_opacity(float, default:0.3) –Minimum heatmap opacity.
-
max_zoom(int, default:18) –Zoom at which points reach full intensity.
-
gradient(dict[float, str] | None, default:None) –Custom gradient
{stop: color}.
config.MapConfig
dataclass
MapConfig(
tile_layer: TileProviderKey
| str
| list[TileProviderKey | str] = "cartodb_positron",
zoom_start: int = 12,
min_zoom: int = 0,
max_zoom: int = 19,
max_native_zoom: int | None = None,
attribution: str | None = None,
width: str | int = "100%",
height: str | int = "100%",
control_scale: bool = True,
fullscreen: bool = False,
minimap: bool = False,
measure_control: bool = False,
home_button: bool = False,
mouse_position: bool = True,
mouse_position_crs: str | None = None,
)
Global map configuration.
Parameters:
-
tile_layer(TileProviderKey | str | list[TileProviderKey | str], default:'cartodb_positron') –Built-in provider key (e.g.
"cartodb_positron") or a raw tile URL string. Pass a list to add multiple base layers (use :meth:Map.add_layer_controlto toggle between them). Built-in keys are auto-completed by IDEs; arbitrary URLs are also accepted as an escape hatch. -
zoom_start(int, default:12) –Initial zoom level.
-
min_zoom(int, default:0) –Minimum zoom level, preventing users from zooming out beyond this level. Lower values allow viewing larger areas like continents. Useful for bounding maps to specific regions.
-
max_zoom(int, default:19) –Maximum zoom level, limiting how far users can zoom in. Higher values enable more detailed views, but effectiveness depends on the tile provider (e.g. OpenStreetMap maxes at 19). Exceeding the provider's limit may show blank tiles unless
max_native_zoomis also set. -
max_native_zoom(int | None, default:None) –Highest zoom level at which the tile provider actually serves tiles. When set below
max_zoom, Leaflet keeps the last native-resolution tile visible (upscaled, so it blurs) instead of rendering blank placeholders.None(default) means Leaflet will request tiles at every zoom level up tomax_zoom, which can produce blank or gray tiles if the provider does not serve them. -
attribution(str | None, default:None) –Custom tile attribution.
-
width(str | int, default:'100%') –Map width.
-
height(str | int, default:'100%') –Map height.
-
control_scale(bool, default:True) –Show scale bar.
-
fullscreen(bool, default:False) –Add fullscreen button.
-
minimap(bool, default:False) –Add minimap inset.
-
measure_control(bool, default:False) –Add measure tool.
-
home_button(bool, default:False) –Add a reset-view button (⌂) that returns the map to its opening center and zoom — the explicit
centerandzoom_startwhen given, otherwise the auto-fitted data bounds. Rendered at the top-right, above the measure control when both are enabled. -
mouse_position(bool, default:True) –Show cursor coordinates.
-
mouse_position_crs(str | None, default:None) –CRS for the cursor-coordinate readout, e.g.
"EPSG:28992"for Dutch RD New.None(default) shows WGS84 lat/lon. Ignored whenmouse_positionisFalse.
config.PopupStyle
dataclass
PopupStyle(
width: int = 300,
height: int = 150,
max_width: int = 300,
use_iframe: bool = True,
)
Popup appearance configuration.
Parameters:
-
width(int, default:300) –IFrame width in pixels. Ignored when
use_iframeis False. -
height(int, default:150) –IFrame height in pixels. Ignored when
use_iframeis False. -
max_width(int, default:300) –Maximum popup width in pixels.
-
use_iframe(bool, default:True) –Render the content in its own IFrame, which shields it from the surrounding page at a fixed
widthxheight. Set to False to put the content straight into the popup: it then sizes to its content, and links can reach the surrounding page. An IFrame is loaded from adata:URL and browsers do not let such a document navigate its parent, so a link withtarget="_top"only works with this set to False.
config.RawJS
RawJS(js: str)
Marker for raw JavaScript that should not be escaped.
Parameters:
-
js(str) –JavaScript function expression that accepts one argument (a GeoJSON FeatureCollection).
Source code in mapyta/config.py
274 275 | |
config.StrokeStyle
dataclass
StrokeStyle(
color: str = "#3388ff",
weight: float = 3.0,
opacity: float = 1.0,
dash_array: str | None = None,
)
Style for lines and polygon borders.
Parameters:
-
color(str, default:'#3388ff') –CSS color string.
-
weight(float, default:3.0) –Stroke width in pixels.
-
opacity(float, default:1.0) –Stroke opacity, 0.0 - 1.0.
-
dash_array(str | None, default:None) –SVG dash-array, e.g.
"5 10".
config.TooltipStyle
dataclass
TooltipStyle(sticky: bool = True, style: str | None = None)
Tooltip appearance configuration.
Parameters:
-
sticky(bool, default:True) –Whether the tooltip follows the mouse cursor.
-
style(str | None, default:None) –Inline CSS style string for the tooltip container. Example:
"font-size:14px; background-color:#fff;"