Skip to content

Markers and controls

maplibre.controls.Popup

Bases: MapLibreBaseModel

Popup

Attributes:

Name Type Description
text str

The Text of the popup.

options PopupOptions | dict

Popup options.

Source code in maplibre/controls.py
class Popup(MapLibreBaseModel):
    """Popup

    Attributes:
        text: The Text of the popup.
        options (PopupOptions | dict): Popup options.
    """

    text: str
    options: Union[PopupOptions, dict] = {}

maplibre.controls.PopupOptions

Bases: MapLibreBaseModel

Popup options

Source code in maplibre/controls.py
class PopupOptions(MapLibreBaseModel):
    """Popup options"""

    anchor: str = None
    close_button: bool = Field(False, serialization_alias="closeButton")
    close_on_click: bool = Field(None, serialization_alias="closeOnClick")
    close_on_move: bool = Field(None, serialization_alias="closeOnMove")
    max_width: int = Field(None, serialization_alias="maxWidth")
    offset: Union[int, list, dict] = None

maplibre.controls.Marker

Bases: MapLibreBaseModel

Marker

Attributes:

Name Type Description
lng_lat tuple | list

Required. The longitude and latitude of the marker.

popup Popup | dict

The Popup that is displayed when a user clicks on the marker.

options MarkerOptions | dict

Marker options.

Source code in maplibre/controls.py
class Marker(MapLibreBaseModel):
    """Marker

    Attributes:
        lng_lat (tuple |list): **Required.** The longitude and latitude of the marker.
        popup (Popup | dict): The Popup that is displayed when a user clicks on the marker.
        options (MarkerOptions | dict): Marker options.
    """

    lng_lat: Union[tuple, list] = Field(None, serialization_alias="lngLat")
    popup: Union[Popup, dict] = None
    options: Union[MarkerOptions, dict] = {}

maplibre.controls.MarkerOptions

Bases: MapLibreBaseModel

Marker options

Source code in maplibre/controls.py
class MarkerOptions(MapLibreBaseModel):
    """Marker options"""

    anchor: str = None
    color: str = None
    draggable: bool = None
    offset: Union[tuple, list] = None
    pitch_alignment: str = Field(None, serialization_alias="pitchAlignment")
    rotation: int = None
    rotation_alignment: str = Field(None, serialization_alias="rotationAlignment")
    scale: int = None

maplibre.controls.ControlPosition

Bases: Enum

Control position

Attributes:

  • TOP_LEFT

    top-left

  • TOP_RIGHT

    top-right

  • BOTTOM_LEFT

    bottom-left

  • BOTTOM_RIGHT

    bottom-right

Source code in maplibre/controls.py
class ControlPosition(Enum):
    """Control position

    Attributes:
        TOP_LEFT: top-left
        TOP_RIGHT: top-right
        BOTTOM_LEFT: bottom-left
        BOTTOM_RIGHT: bottom-right
    """

    TOP_LEFT = "top-left"
    TOP_RIGHT = "top-right"
    BOTTOM_LEFT = "bottom-left"
    BOTTOM_RIGHT = "bottom-right"

maplibre.controls.FullscreenControl

Bases: Control

Fullscreen control

Examples:

>>> from maplibre import Map
>>> from maplibre.controls import FullscreenControl, ControlPosition
>>> m = Map()
>>> m.add_control(FullscreenControl(), ControlPosition.BOTTOM_LEFT)
Source code in maplibre/controls.py
class FullscreenControl(Control):
    """Fullscreen control

    Examples:
        >>> from maplibre import Map
        >>> from maplibre.controls import FullscreenControl, ControlPosition

        >>> m = Map()
        >>> m.add_control(FullscreenControl(), ControlPosition.BOTTOM_LEFT)
    """

    # _name: str = ControlType.FULLSCREEN.value
    pass

maplibre.controls.ScaleControl

Bases: Control

Scale control

Source code in maplibre/controls.py
class ScaleControl(Control):
    """Scale control"""

    max_width: int = Field(None, serialization_alias="maxWidth")
    unit: Literal["imperial", "metric", "nautical"] = "metric"

maplibre.controls.NavigationControl

Bases: Control

Navigation control

Source code in maplibre/controls.py
class NavigationControl(Control):
    """Navigation control"""

    # _name: str = ControlType.NAVIGATION.value
    show_compass: bool = Field(True, serialization_alias="showCompass")
    show_zoom: bool = Field(True, serialization_alias="showZoom")
    visualize_pitch: bool = Field(False, serialization_alias="visualizePitch")

maplibre.controls.GeolocateControl

Bases: Control

Geolocate control

Source code in maplibre/controls.py
class GeolocateControl(Control):
    """Geolocate control"""

    # _name: str = ControlType.GEOLOCATE.value
    position_options: dict = Field(None, serialization_alias="positionOptions")
    show_accuracy_circle: bool = Field(True, serialization_alias="showAccuracyCircle")
    show_user_heading: bool = Field(False, serialization_alias="showUserHeading")
    show_user_location: bool = Field(True, serialization_alias="showUserLocation")
    track_user_location: bool = Field(False, serialization_alias="trackUserLocation")

maplibre.controls.GlobeControl

Bases: Control

Globe control

Source code in maplibre/controls.py
class GlobeControl(Control):
    """Globe control"""

    ...

maplibre.controls.TerrainControl

Bases: Control

Terrain control

Source code in maplibre/controls.py
class TerrainControl(Control):
    """Terrain control"""

    source: str
    exaggeration: Union[int, float] = 1

maplibre.controls.MapTilerGeocodingControl

Bases: Control

MapTiler Geocoding Control

Note

See maptiler-geocoding-api-reference for details.

Source code in maplibre/controls.py
class MapTilerGeocodingControl(Control):
    """MapTiler Geocoding Control

    Note:
        See [maptiler-geocoding-api-reference](https://docs.maptiler.com/sdk-js/modules/geocoding/api/api-reference/) for details.
    """

    api_key: str = Field(options.maptiler_api_key, serialization_alias="apiKey")
    api_url: str | None = Field(None, serialization_alias="apiUrl")
    bbox: tuple[float, float, float, float] | None = None
    clear_button_title: str | None = Field("clear", serialization_alias="clearButtonTitle")
    clear_list_on_pick: bool | None = Field(False, serialization_alias="clearListOnPick")
    clear_on_blur: bool | None = Field(False, serialization_alias="clearOnBlur")
    collapsed: bool | None = False
    country: str | None = None
    debounce_search: int | None = Field(200, serialization_alias="debounceSearch")
    enable_reverse: Literal["always", "button", "never"] | None = Field("never", serialization_alias="enableReverse")
    fuzzy_match: bool | None = Field(True, serialization_alias="fuzzyMatch")
    limit: int | None = 5
    marker_on_selected: bool | None = Field(True, serialization_alias="markerOnSelected")
    min_length: int | None = Field(2, serialization_alias="minLength")
    placeholder: str | None = "Search"

maplibre.controls.InfoBoxControl

Bases: Control

InfoBox control

Attributes:

Name Type Description
content str

Content (HTML or plain text) to be displayed in the info box.

css_text str

Optional inline style declaration of the control.

Source code in maplibre/controls.py
class InfoBoxControl(Control):
    """InfoBox control

    Attributes:
        content (str): Content (HTML or plain text) to be displayed in the info box.
        css_text (str): Optional inline style declaration of the control.
    """

    content: str
    css_text: str = Field(None, serialization_alias="cssText")

maplibre.controls.LayerSwitcherControl

Bases: Control

Layer switcher control

Attributes:

Name Type Description
layer_ids list

A list of layer ids to be shown in the layer switcher control.

theme Literal['default', 'simple']

The theme of the layer switcher control.

css_text str

Optional inline style declaration of the control.

Source code in maplibre/controls.py
class LayerSwitcherControl(Control):
    """Layer switcher control

    Attributes:
        layer_ids (list): A list of layer ids to be shown in the layer switcher control.
        theme (Literal["default", "simple"]): The theme of the layer switcher control.
        css_text (str): Optional inline style declaration of the control.
    """

    layer_ids: list = Field([], serialization_alias="layerIds")
    theme: Literal["default", "simple"] = "default"
    css_text: str = Field(None, serialization_alias="cssText")