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

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 edit/delete controls are active.

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,
    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,
    mouse_position: bool = True,
)

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.

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

  • mouse_position (bool, default: True ) –

    Show cursor coordinates.

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