Skip to content

config

config

Style configuration dataclasses for Mapyta.

Classes:

  • CircleStyle

    Style for circle markers (fixed pixel size).

  • 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:

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 ) –

    shapeOptions override 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. When False, 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_control to 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_zoom is 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 to max_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 center and zoom_start when 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 when mouse_position is False.

config.PopupStyle dataclass

PopupStyle(width: int = 300, height: int = 150, max_width: int = 300)

Popup appearance configuration.

Parameters:

  • width (int, default: 300 ) –

    IFrame width in pixels.

  • height (int, default: 150 ) –

    IFrame height in pixels.

  • max_width (int, default: 300 ) –

    Maximum popup width in pixels.

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
216
217
def __init__(self, js: str) -> None:
    self.js = js

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;"