From 11ba01097029106947ed9c3b89440754191da874 Mon Sep 17 00:00:00 2001 From: Stefan Kuethe Date: Wed, 3 Jan 2024 15:04:28 +0100 Subject: [PATCH] Deployed 9558a33 with MkDocs version: 1.5.3 --- 404.html | 495 ++- api/basemaps/index.html | 943 ++++++ api/controls/index.html | 1412 ++++++++ api/layer/index.html | 1236 +++++++ api/map/index.html | 2191 ++++++++++++ api/sources/index.html | 1044 ++++++ .../basic_usage_shiny.cpython-39.pyc | Bin 0 -> 1143 bytes .../airports/__pycache__/app.cpython-39.pyc | Bin 0 -> 2279 bytes .../airports/__pycache__/app2.cpython-39.pyc | Bin 0 -> 2990 bytes .../airports/__pycache__/app3.cpython-39.pyc | Bin 0 -> 2906 bytes .../airports/__pycache__/app4.cpython-39.pyc | Bin 0 -> 1601 bytes examples/airports/app.py | 94 + examples/airports/index.html | 833 +++++ examples/basic_usage.py | 26 + examples/basic_usage_shiny.py | 27 + .../__pycache__/app.cpython-39.pyc | Bin 0 -> 2430 bytes examples/earthquake_clusters/app.py | 98 + examples/earthquake_clusters/index.html | 839 +++++ .../__pycache__/app.cpython-39.pyc | Bin 0 -> 2284 bytes .../__pycache__/app2.cpython-39.pyc | Bin 0 -> 2990 bytes .../__pycache__/app3.cpython-39.pyc | Bin 0 -> 2906 bytes .../__pycache__/app4.cpython-39.pyc | Bin 0 -> 1601 bytes examples/every_person_in_manhattan/app.py | 78 + examples/every_person_in_manhattan/index.html | 819 +++++ index.html | 3010 +++-------------- objects.inv | Bin 376 -> 508 bytes search/search_index.json | 1 + sitemap.xml.gz | Bin 127 -> 127 bytes theme/main.html | 11 + 29 files changed, 10693 insertions(+), 2464 deletions(-) create mode 100644 api/basemaps/index.html create mode 100644 api/controls/index.html create mode 100644 api/layer/index.html create mode 100644 api/map/index.html create mode 100644 api/sources/index.html create mode 100644 examples/__pycache__/basic_usage_shiny.cpython-39.pyc create mode 100644 examples/airports/__pycache__/app.cpython-39.pyc create mode 100644 examples/airports/__pycache__/app2.cpython-39.pyc create mode 100644 examples/airports/__pycache__/app3.cpython-39.pyc create mode 100644 examples/airports/__pycache__/app4.cpython-39.pyc create mode 100644 examples/airports/app.py create mode 100644 examples/airports/index.html create mode 100644 examples/basic_usage.py create mode 100644 examples/basic_usage_shiny.py create mode 100644 examples/earthquake_clusters/__pycache__/app.cpython-39.pyc create mode 100644 examples/earthquake_clusters/app.py create mode 100644 examples/earthquake_clusters/index.html create mode 100644 examples/every_person_in_manhattan/__pycache__/app.cpython-39.pyc create mode 100644 examples/every_person_in_manhattan/__pycache__/app2.cpython-39.pyc create mode 100644 examples/every_person_in_manhattan/__pycache__/app3.cpython-39.pyc create mode 100644 examples/every_person_in_manhattan/__pycache__/app4.cpython-39.pyc create mode 100644 examples/every_person_in_manhattan/app.py create mode 100644 examples/every_person_in_manhattan/index.html create mode 100644 search/search_index.json create mode 100644 theme/main.html diff --git a/404.html b/404.html index 5009e8c2..e7d2104a 100644 --- a/404.html +++ b/404.html @@ -16,19 +16,28 @@ - pymaplibregl + Pymaplibregl + + + + + + + + + @@ -51,7 +60,12 @@ - + + + + + + @@ -67,11 +81,9 @@ - - -
+
@@ -113,6 +174,69 @@ + + +
@@ -126,18 +250,32 @@ + - - - - -
  • - - - map - - - - - -
  • - -
  • - - - sources - - - - - -
  • - - - - - - - - - - -
    -
    - - - - -

    PyMapLibreGL

    - - -
    - - - - -

    - pymaplibregl.basemaps - - -

    - -
    - - - -
    - - - - - - - - -
    - - - - -

    - Carto - - -

    - - -
    -

    - Bases: Enum

    - - -

    Carto basemap styles

    - - - -

    Attributes:

    -
      -
    • - DARK_MATTER - – -
      -

      dark-matter

      -
      -
    • -
    • - POSITRON - – -
      -

      positron

      -
      -
    • -
    • - VOYAGER - – -
      -

      voyager

      -
      -
    • -
    • - POSITRON_NOLABELS - – -
      -

      positron-nolabels

      -
      -
    • -
    • - DARK_MATTER_NOLABELS - – -
      -

      dark-matter-nolabels

      -
      -
    • -
    • - VOYAGER_NOLABELS - – -
      -

      voyager-nolabels

      -
      -
    • -
    - - - -

    Examples:

    -
    >>> from pymaplibregl import Map, MapOptions
    ->>> from pymaplibregl.basemaps import Carto
    -
    -
    >>> map = Map(MapOptions(style=Carto.DARK_MATTER))
    -
    - -
    - Source code in pymaplibregl/basemaps.py -
     8
    - 9
    -10
    -11
    -12
    -13
    -14
    -15
    -16
    -17
    -18
    -19
    -20
    -21
    -22
    -23
    -24
    -25
    -26
    -27
    -28
    -29
    -30
    -31
    class Carto(Enum):
    -    """Carto basemap styles
    -
    -    Attributes:
    -        DARK_MATTER: dark-matter
    -        POSITRON: positron
    -        VOYAGER: voyager
    -        POSITRON_NOLABELS: positron-nolabels
    -        DARK_MATTER_NOLABELS: dark-matter-nolabels
    -        VOYAGER_NOLABELS: voyager-nolabels
    -
    -    Examples:
    -        >>> from pymaplibregl import Map, MapOptions
    -        >>> from pymaplibregl.basemaps import Carto
    -
    -        >>> map = Map(MapOptions(style=Carto.DARK_MATTER))
    -    """
    -
    -    DARK_MATTER = "dark-matter"
    -    POSITRON = "positron"
    -    VOYAGER = "voyager"
    -    POSITRON_NOLABELS = "positron-nolabels"
    -    DARK_MATTER_NOLABELS = "dark-matter-nolabels"
    -    VOYAGER_NOLABELS = "voyager-nolabels"
    -
    -
    - - - -
    - - - - - - - - - - - -
    - -
    - -
    - - - - -
    - -
    - -
    - -
    - - - - -

    - pymaplibregl.controls - - -

    - -
    - - - -
    - - - - - - - - -
    - - - - -

    - Marker - - -

    - - -
    -

    - Bases: BaseModel

    - - -

    Marker

    - - - -

    Attributes:

    -
      -
    • - lng_lat - ((tuple, list)) - – -
      -

      Required. The longitude and latitude of the marker.

      -
      -
    • -
    • - popup - ((Popup, dict)) - – -
      -

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

      -
      -
    • -
    • - options - ((MarkerOptions, dict)) - – -
      -

      Marker options.

      -
      -
    • -
    - -
    - Source code in pymaplibregl/controls.py -
    55
    -56
    -57
    -58
    -59
    -60
    -61
    -62
    -63
    -64
    -65
    -66
    class Marker(BaseModel):
    -    """Marker
    -
    -    Attributes:
    -        lng_lat (tuple, list): **Required.** The longitude and latitude of the marker.
    -        popup (Popup, dict): A 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] = {}
    -
    -
    - - - -
    - - - - - - - - - - - -
    - -
    - -
    - -
    - - - - -

    - MarkerOptions - - -

    - - -
    -

    - Bases: BaseModel

    - - -

    Marker options

    - -
    - Source code in pymaplibregl/controls.py -
    42
    -43
    -44
    -45
    -46
    -47
    -48
    -49
    -50
    -51
    -52
    class MarkerOptions(BaseModel):
    -    """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
    -
    -
    - - - -
    - - - - - - - - - - - -
    - -
    - -
    - -
    - - - - -

    - Popup - - -

    - - -
    -

    - Bases: BaseModel

    - - -

    Popup

    - - - -

    Attributes:

    -
      -
    • - text - (str) - – -
      -

      The Text of the popup.

      -
      -
    • -
    • - options - (PopupOptions | dict) - – -
      -

      Popup options.

      -
      -
    • -
    - -
    - Source code in pymaplibregl/controls.py -
    22
    -23
    -24
    -25
    -26
    -27
    -28
    -29
    -30
    -31
    class Popup(BaseModel):
    -    """Popup
    -
    -    Attributes:
    -        text: The Text of the popup.
    -        options (PopupOptions | dict): Popup options.
    -    """
    -
    -    text: str
    -    options: Union[PopupOptions, dict] = {}
    -
    -
    - - - -
    - - - - - - - - - - - -
    - -
    - -
    - -
    - - - - -

    - PopupOptions - - -

    - - -
    -

    - Bases: BaseModel

    - - -

    Popup options

    - -
    - Source code in pymaplibregl/controls.py -
    11
    -12
    -13
    -14
    -15
    -16
    -17
    -18
    -19
    class PopupOptions(BaseModel):
    -    """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
    -
    -
    - - - -
    - - - - - - - - - - - -
    - -
    - -
    - - - - -
    - -
    - -
    - -
    - - - - -

    - pymaplibregl.layer - - -

    - -
    - - - -
    - - - - - - - - -
    - - - - -

    - Layer - - -

    - - -
    -

    - Bases: BaseModel

    - - -

    Layer properties

    - -
    - Notes -

    See layers for more details.

    -
    - - -

    Attributes:

    -
      -
    • - id - (str) - – -
      -

      Required. The unique ID of the layer. Defaults to str(uuid4()).

      -
      -
    • -
    • - type - (str | LayerType) - – -
      -

      Required. The type of the layer.

      -
      -
    • -
    • - filter - (list) - – -
      -

      The filter expression that is applied to the source of the layer.

      -
      -
    • -
    • - layout - (dict) - – -
      -

      The layout properties of the layer.

      -
      -
    • -
    • - source - (str | Source) - – -
      -

      The name (unique ID) of a source or a source object to be used for the layer.

      -
      -
    • -
    • - source_layer - (str) - – -
      -

      The layer to use from a vector tile source.

      -
      -
    • -
    - - - -

    Examples:

    -
    >>> from pymaplibregl.layer import Layer, LayerType
    -
    -
    >>> layer = Layer(id="test-layer", type=LayerType.CIRCLE, source="test-source")
    -
    - -
    - Source code in pymaplibregl/layer.py -
    39
    -40
    -41
    -42
    -43
    -44
    -45
    -46
    -47
    -48
    -49
    -50
    -51
    -52
    -53
    -54
    -55
    -56
    -57
    -58
    -59
    -60
    -61
    -62
    -63
    -64
    -65
    -66
    -67
    -68
    -69
    -70
    -71
    -72
    -73
    -74
    -75
    -76
    -77
    -78
    -79
    -80
    -81
    -82
    -83
    -84
    -85
    class Layer(BaseModel):
    -    """Layer properties
    -
    -    Notes:
    -        See [layers](https://maplibre.org/maplibre-style-spec/layers/) for more details.
    -
    -    Attributes:
    -        id (str): **Required.** The unique ID of the layer. Defaults to `str(uuid4())`.
    -        type (str | LayerType): **Required.** The type of the layer.
    -        filter (list): The filter expression that is applied to the source of the layer.
    -        layout (dict): The layout properties of the layer.
    -        max_zoom (int) The maximum zoom level for the layer.
    -        min_zoom (int) The minimum zoom level for the layer.
    -        paint (dict) The paint properties of the layer.
    -        source (str | Source): The name (unique ID) of a source or a source object to be used for the layer.
    -        source_layer (str): The layer to use from a vector tile source.
    -
    -    Examples:
    -        >>> from pymaplibregl.layer import Layer, LayerType
    -
    -        >>> layer = Layer(id="test-layer", type=LayerType.CIRCLE, source="test-source")
    -    """
    -
    -    id: str = str(uuid4())
    -    type: LayerType
    -    filter: list = None
    -    layout: dict = None
    -    max_zoom: int = Field(None, serialization_alias="maxzoom")
    -    metadata: dict = None
    -    min_zoom: int = Field(None, serialization_alias="minzoom")
    -    paint: dict = None
    -    source: Union[str, Source, dict, None] = None
    -    source_layer: str = Field(None, serialization_alias="source-layer")
    -
    -    @field_validator("source")
    -    def validate_source(cls, v):
    -        if isinstance(v, Source):
    -            return v.to_dict()
    -
    -        return v
    -
    -    @field_validator("paint", "layout")
    -    def fix_paint(cls, v):
    -        if isinstance(v, dict):
    -            return fix_keys(v)
    -
    -        return v
    -
    -
    - - - -
    - - - - - - - - - - - -
    - -
    - -
    - -
    - - - - -

    - LayerType - - -

    - - -
    -

    - Bases: str, Enum

    - - -

    Rendering type of layer

    - - - -

    Attributes:

    -
      -
    • - CIRCLE - – -
      -

      A filled circle.

      -
      -
    • -
    • - FILL - – -
      -

      A filled polygon with an optional stroked border.

      -
      -
    • -
    • - FILL_EXTRUSION - – -
      -

      An extruded polygon.

      -
      -
    • -
    • - LINE - – -
      -

      A stroked line.

      -
      -
    • -
    • - SYMBOL - – -
      -

      An icon or a text label.

      -
      -
    • -
    • - RASTER - – -
      -

      Raster map textures such as satellite imagery.

      -
      -
    • -
    • - HEATMAP - – -
      -

      A heatmap.

      -
      -
    • -
    • - HILLSHADE - – -
      -

      A Client-side hillshading visualization based on DEM data.

      -
      -
    • -
    • - BACKGROUND - – -
      -

      A background color or pattern.

      -
      -
    • -
    - -
    - Source code in pymaplibregl/layer.py -
    13
    -14
    -15
    -16
    -17
    -18
    -19
    -20
    -21
    -22
    -23
    -24
    -25
    -26
    -27
    -28
    -29
    -30
    -31
    -32
    -33
    -34
    -35
    -36
    class LayerType(str, Enum):
    -    """Rendering type of layer
    -
    -    Attributes:
    -        CIRCLE: A filled circle.
    -        FILL: A filled polygon with an optional stroked border.
    -        FILL_EXTRUSION: An extruded polygon.
    -        LINE: A stroked line.
    -        SYMBOL: An icon or a text label.
    -        RASTER: Raster map textures such as satellite imagery.
    -        HEATMAP: A heatmap.
    -        HILLSHADE: A Client-side hillshading visualization based on DEM data.
    -        BACKGROUND: A background color or pattern.
    -    """
    -
    -    CIRCLE = "circle"
    -    FILL = "fill"
    -    FILL_EXTRUSION = "fill-extrusion"
    -    LINE = "line"
    -    SYMBOL = "symbol"
    -    RASTER = "raster"
    -    HEATMAP = "heatmap"
    -    HILLSHADE = "hillshade"
    -    BACKGROUND = "background"
    -
    -
    - - - -
    - - - - - - - - - - - -
    - -
    - -
    - - - - -
    - -
    - -
    - -
    - - - - -

    - pymaplibregl.map - - -

    - -
    - - - -
    - - - - - - - - -
    - - - - -

    - Map - - -

    - - -
    -

    - Bases: object

    - - -

    Map

    - - - -

    Parameters:

    -
      -
    • - map_options - (MapOptions, default: - MapOptions() -) - – -
      -

      Map options.

      -
      -
    • -
    • - **kwargs - – -
      -

      Keyword arguments that are appended to the MapOptions object.

      -
      -
    • -
    - - - -

    Examples:

    -
    >>> from pymaplibregl.map import Map, MapOptions
    -
    -
    >>> map_options = MapOptions(center=(9.5, 51.31667), zoom=8)
    ->>> map = Map(map_options)
    ->>> dict(map)
    -{'mapOptions': {'center': (9.5, 51.31667), 'style': 'https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json', 'zoom': 8}, 'calls': []}
    -
    - -
    - Source code in pymaplibregl/map.py -
     61
    - 62
    - 63
    - 64
    - 65
    - 66
    - 67
    - 68
    - 69
    - 70
    - 71
    - 72
    - 73
    - 74
    - 75
    - 76
    - 77
    - 78
    - 79
    - 80
    - 81
    - 82
    - 83
    - 84
    - 85
    - 86
    - 87
    - 88
    - 89
    - 90
    - 91
    - 92
    - 93
    - 94
    - 95
    - 96
    - 97
    - 98
    - 99
    -100
    -101
    -102
    -103
    -104
    -105
    -106
    -107
    -108
    -109
    -110
    -111
    -112
    -113
    -114
    -115
    -116
    -117
    -118
    -119
    -120
    -121
    -122
    -123
    -124
    -125
    -126
    -127
    -128
    -129
    -130
    -131
    -132
    -133
    -134
    -135
    -136
    -137
    -138
    -139
    -140
    -141
    -142
    -143
    -144
    -145
    -146
    -147
    -148
    -149
    -150
    -151
    -152
    -153
    -154
    -155
    -156
    -157
    -158
    -159
    -160
    -161
    -162
    -163
    -164
    -165
    -166
    -167
    -168
    -169
    -170
    -171
    -172
    -173
    -174
    -175
    -176
    -177
    -178
    -179
    -180
    -181
    -182
    -183
    -184
    -185
    -186
    -187
    class Map(object):
    -    """Map
    -
    -    Args:
    -        map_options (MapOptions): Map options.
    -        **kwargs: Keyword arguments that are appended to the `MapOptions` object.
    -
    -    Examples:
    -        >>> from pymaplibregl.map import Map, MapOptions
    -
    -        >>> map_options = MapOptions(center=(9.5, 51.31667), zoom=8)
    -        >>> map = Map(map_options)
    -        >>> dict(map)
    -        {'mapOptions': {'center': (9.5, 51.31667), 'style': 'https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json', 'zoom': 8}, 'calls': []}
    -    """
    -
    -    MESSAGE = "not implemented yet"
    -
    -    def __init__(self, map_options: MapOptions = MapOptions(), **kwargs):
    -        self._map_options = map_options.to_dict() | kwargs
    -        self._calls = []
    -
    -    def __iter__(self):
    -        for k, v in self.to_dict().items():
    -            yield k, v
    -
    -    def to_dict(self) -> dict:
    -        return {"mapOptions": self._map_options, "calls": self._calls}
    -
    -    @property
    -    def sources(self) -> list:
    -        return [item["data"] for item in self._calls if item["name"] == "addSource"]
    -
    -    @property
    -    def layers(self) -> list:
    -        return [item["data"] for item in self._calls if item["name"] == "addLayer"]
    -
    -    # TODO: Rename to add_map_call
    -    def add_call(self, func_name: str, params: list) -> None:
    -        self._calls.append(
    -            {"name": "applyFunc", "data": {"funcName": func_name, "params": params}}
    -        )
    -
    -    def add_control(
    -        self,
    -        control: Control,
    -        position: [str | ControlPosition] = ControlPosition.TOP_RIGHT,
    -    ) -> None:
    -        """Add a control to the map"""
    -        data = {
    -            "type": control.type,
    -            "options": control.to_dict(),
    -            "position": ControlPosition(position).value,
    -        }
    -        self._calls.append({"name": "addControl", "data": data})
    -
    -    def add_source(self, id: str, source: [Source | dict]) -> None:
    -        """Add a source to the map"""
    -        if isinstance(source, Source):
    -            source = source.to_dict()
    -
    -        self._calls.append({"name": "addSource", "data": {"id": id, "source": source}})
    -
    -    def add_layer(self, layer: [Layer | dict]) -> None:
    -        """Add a layer to the map
    -
    -        Args:
    -            layer (Layer | dict): The Layer to be added to the map.
    -        """
    -        if isinstance(layer, Layer):
    -            layer = layer.to_dict()
    -
    -        self._calls.append({"name": "addLayer", "data": layer})
    -
    -    def add_marker(self, marker: Marker) -> None:
    -        """Add a marker to the map"""
    -        self._calls.append({"name": "addMarker", "data": marker.to_dict()})
    -
    -    def add_popup(self, layer_id: str, prop: str) -> None:
    -        """Add a popup to the map"""
    -        self._calls.append(
    -            {"name": "addPopup", "data": {"layerId": layer_id, "property": prop}}
    -        )
    -
    -    def set_filter(self, layer_id: str, filter_: list):
    -        """Update the filter of a layer
    -
    -        Args:
    -            layer_id (str): The name of the layer to be updated.
    -            filter_ (list): The filter expression that is applied to the source of the layer.
    -        """
    -        self.add_call("setFilter", [layer_id, filter_])
    -
    -    def set_paint_property(self, layer_id: str, prop: str, value: any) -> None:
    -        """Update the paint property of a layer
    -
    -        Args:
    -            layer_id (str): The name of the layer to be updated.
    -            prop (str): The name of the paint property to be updated.
    -            value (any): The new value of the paint property.
    -        """
    -        self.add_call("setPaintProperty", [layer_id, prop, value])
    -
    -    def set_layout_property(self, layer_id: str, prop: str, value: any) -> None:
    -        """Update a layout property of a layer
    -
    -        Args:
    -            layer_id (str): The name of the layer to be updated.
    -            prop (str): The name of the layout property to be updated.
    -            value (any): The new value of the layout property.
    -        """
    -        self.add_call("setLayoutProperty", [layer_id, prop, value])
    -
    -    def to_html(self, output_dir: str = None, **kwargs) -> str:
    -        js_lib = read_internal_file("srcjs", "index.js")
    -        js_snippet = Template(js_template).render(data=json.dumps(self.to_dict()))
    -        output = Template(html_template).render(
    -            js="\n".join([js_lib, js_snippet]), **kwargs
    -        )
    -        if output_dir == "skip":
    -            return output
    -
    -        file_name = os.path.join(get_output_dir(output_dir), "index.html")
    -        with open(file_name, "w") as f:
    -            f.write(output)
    -
    -        return file_name
    -
    -
    - - - -
    - - - - - - - - - - -
    - - - - -

    - add_control(control, position=ControlPosition.TOP_RIGHT) - -

    - - -
    - -

    Add a control to the map

    - -
    - Source code in pymaplibregl/map.py -
    104
    -105
    -106
    -107
    -108
    -109
    -110
    -111
    -112
    -113
    -114
    -115
    def add_control(
    -    self,
    -    control: Control,
    -    position: [str | ControlPosition] = ControlPosition.TOP_RIGHT,
    -) -> None:
    -    """Add a control to the map"""
    -    data = {
    -        "type": control.type,
    -        "options": control.to_dict(),
    -        "position": ControlPosition(position).value,
    -    }
    -    self._calls.append({"name": "addControl", "data": data})
    -
    -
    -
    - -
    - - -
    - - - - -

    - add_layer(layer) - -

    - - -
    - -

    Add a layer to the map

    - - - -

    Parameters:

    -
      -
    • - layer - (Layer | dict) - – -
      -

      The Layer to be added to the map.

      -
      -
    • -
    - -
    - Source code in pymaplibregl/map.py -
    124
    -125
    -126
    -127
    -128
    -129
    -130
    -131
    -132
    -133
    def add_layer(self, layer: [Layer | dict]) -> None:
    -    """Add a layer to the map
    -
    -    Args:
    -        layer (Layer | dict): The Layer to be added to the map.
    -    """
    -    if isinstance(layer, Layer):
    -        layer = layer.to_dict()
    -
    -    self._calls.append({"name": "addLayer", "data": layer})
    -
    -
    -
    - -
    - - -
    - - - - -

    - add_marker(marker) - -

    - - -
    - -

    Add a marker to the map

    - -
    - Source code in pymaplibregl/map.py -
    135
    -136
    -137
    def add_marker(self, marker: Marker) -> None:
    -    """Add a marker to the map"""
    -    self._calls.append({"name": "addMarker", "data": marker.to_dict()})
    -
    -
    -
    - -
    - - -
    - - - - -

    - add_popup(layer_id, prop) - -

    - - -
    - -

    Add a popup to the map

    - -
    - Source code in pymaplibregl/map.py -
    139
    -140
    -141
    -142
    -143
    def add_popup(self, layer_id: str, prop: str) -> None:
    -    """Add a popup to the map"""
    -    self._calls.append(
    -        {"name": "addPopup", "data": {"layerId": layer_id, "property": prop}}
    -    )
    -
    -
    -
    - -
    - - -
    - - - - -

    - add_source(id, source) - -

    - - -
    - -

    Add a source to the map

    - -
    - Source code in pymaplibregl/map.py -
    117
    -118
    -119
    -120
    -121
    -122
    def add_source(self, id: str, source: [Source | dict]) -> None:
    -    """Add a source to the map"""
    -    if isinstance(source, Source):
    -        source = source.to_dict()
    -
    -    self._calls.append({"name": "addSource", "data": {"id": id, "source": source}})
    -
    -
    -
    - -
    - - -
    - - - - -

    - set_filter(layer_id, filter_) - -

    - - -
    - -

    Update the filter of a layer

    - - - -

    Parameters:

    -
      -
    • - layer_id - (str) - – -
      -

      The name of the layer to be updated.

      -
      -
    • -
    • - filter_ - (list) - – -
      -

      The filter expression that is applied to the source of the layer.

      -
      -
    • -
    - -
    - Source code in pymaplibregl/map.py -
    145
    -146
    -147
    -148
    -149
    -150
    -151
    -152
    def set_filter(self, layer_id: str, filter_: list):
    -    """Update the filter of a layer
    -
    -    Args:
    -        layer_id (str): The name of the layer to be updated.
    -        filter_ (list): The filter expression that is applied to the source of the layer.
    -    """
    -    self.add_call("setFilter", [layer_id, filter_])
    -
    -
    -
    - -
    - - -
    - - - - -

    - set_layout_property(layer_id, prop, value) - -

    - - -
    - -

    Update a layout property of a layer

    - - - -

    Parameters:

    -
      -
    • - layer_id - (str) - – -
      -

      The name of the layer to be updated.

      -
      -
    • -
    • - prop - (str) - – -
      -

      The name of the layout property to be updated.

      -
      -
    • -
    • - value - (any) - – -
      -

      The new value of the layout property.

      -
      -
    • -
    - -
    - Source code in pymaplibregl/map.py -
    164
    -165
    -166
    -167
    -168
    -169
    -170
    -171
    -172
    def set_layout_property(self, layer_id: str, prop: str, value: any) -> None:
    -    """Update a layout property of a layer
    -
    -    Args:
    -        layer_id (str): The name of the layer to be updated.
    -        prop (str): The name of the layout property to be updated.
    -        value (any): The new value of the layout property.
    -    """
    -    self.add_call("setLayoutProperty", [layer_id, prop, value])
    -
    -
    -
    - -
    - - -
    - - - - -

    - set_paint_property(layer_id, prop, value) - -

    - - -
    - -

    Update the paint property of a layer

    - - - -

    Parameters:

    -
      -
    • - layer_id - (str) - – -
      -

      The name of the layer to be updated.

      -
      -
    • -
    • - prop - (str) - – -
      -

      The name of the paint property to be updated.

      -
      -
    • -
    • - value - (any) - – -
      -

      The new value of the paint property.

      -
      -
    • -
    - -
    - Source code in pymaplibregl/map.py -
    154
    -155
    -156
    -157
    -158
    -159
    -160
    -161
    -162
    def set_paint_property(self, layer_id: str, prop: str, value: any) -> None:
    -    """Update the paint property of a layer
    -
    -    Args:
    -        layer_id (str): The name of the layer to be updated.
    -        prop (str): The name of the paint property to be updated.
    -        value (any): The new value of the paint property.
    -    """
    -    self.add_call("setPaintProperty", [layer_id, prop, value])
    -
    -
    -
    - -
    - - - -
    - -
    - -
    - -
    - - - - -

    - MapOptions - - -

    - - -
    -

    - Bases: BaseModel

    - -

    Map options

    -
    - Note -

    See mapOptions for more details.

    -
    -
    - Source code in pymaplibregl/map.py -
    18
    -19
    -20
    -21
    -22
    -23
    -24
    -25
    -26
    -27
    -28
    -29
    -30
    -31
    -32
    -33
    -34
    -35
    -36
    -37
    -38
    -39
    -40
    -41
    -42
    -43
    -44
    -45
    -46
    -47
    -48
    -49
    -50
    -51
    -52
    -53
    -54
    -55
    -56
    -57
    -58
    class MapOptions(BaseModel):
    -    """Map options
     
    -    Note:
    -        See [mapOptions](https://maplibre.org/maplibre-gl-js/docs/API/types/maplibregl.MapOptions/) for more details.
    -    """
    -
    -    model_config = ConfigDict(
    -        validate_assignment=True, extra="forbid", use_enum_values=False
    -    )
    -    antialias: bool = None
    -    attribution_control: bool = Field(None, serialization_alias="attributionControl")
    -    bearing: int = None
    -    bearing_snap: int = Field(None, serialization_alias="bearingSnap")
    -    bounds: tuple = None
    -    box_zoom: bool = Field(None, serialization_alias="boxZoom")
    -    center: tuple = None
    -    click_tolerance: int = Field(None, serialization_alias="clickTolerance")
    -    custom_attribution: bool = Field(None, serialization_alias="customAttribution")
    -    double_click_zoom: bool = Field(None, serialization_alias="doubleClickZoom")
    -    fade_duration: int = Field(None, serialization_alias="fadeDuration")
    -    fit_bounds_options: dict = Field(None, serialization_alias="fitBoundsOptions")
    -    hash: Union[bool, str] = None
    -    interactive: bool = None
    -    keyword: bool = None
    -    max_bounds: tuple = Field(None, serialization_alias="maxBounds")
    -    max_pitch: int = Field(None, serialization_alias="maxPitch")
    -    max_zoom: int = Field(None, serialization_alias="maxZoom")
    -    min_pitch: int = Field(None, serialization_alias="minPitch")
    -    min_zoom: int = Field(None, serialization_alias="minZoom")
    -    pitch: int = None
    -    scroll_zoom: bool = Field(None, serialization_alias="scrollZoom")
    -    style: Union[str, Carto] = construct_carto_basemap_url(Carto.DARK_MATTER)
    -    zoom: int = None
    -
    -    @field_validator("style")
    -    def validate_style(cls, v):
    -        if isinstance(v, Carto):
    -            return construct_carto_basemap_url(v)
    -
    -        return v
    -
    -
    - - - -
    - - - - - - - - - - - -
    - -
    - -
    - - - - -
    - -
    - -
    - -
    - - - - -

    - pymaplibregl.sources - - -

    - -
    - - - -
    - - - - - - - - -
    - - - - -

    - GeoJSONSource - - -

    - - -
    -

    - Bases: Source

    - - -

    GeoJSON Source

    - - - -

    Examples:

    -
    >>> from pymaplibregl.sources import GeoJSONSource
    -
    -
    >>> source = GeoJSONSource(data="https://docs.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson")
    -
    - -
    - Source code in pymaplibregl/sources.py -
    32
    -33
    -34
    -35
    -36
    -37
    -38
    -39
    -40
    -41
    -42
    -43
    -44
    -45
    -46
    -47
    -48
    -49
    -50
    -51
    -52
    -53
    -54
    -55
    -56
    -57
    -58
    -59
    class GeoJSONSource(Source):
    -    """GeoJSON Source
    -
    -    Examples:
    -        >>> from pymaplibregl.sources import GeoJSONSource
    -
    -        >>> source = GeoJSONSource(data="https://docs.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson")
    -    """
    -
    -    data: Union[str, dict]
    -    attribution: str = None
    -    buffer: int = None
    -    cluster: bool = None
    -    cluster_max_zoom: int = Field(None, serialization_alias="clusterMaxZoom")
    -    cluster_min_points: int = Field(None, serialization_alias="clusterMinPoints")
    -    cluster_properties: dict = Field(None, serialization_alias="clusterProperties")
    -    cluster_radius: int = Field(None, serialization_alias="clusterRadius")
    -    filter: list = None
    -    generate_id: bool = Field(None, serialization_alias="generateId")
    -    line_metrics: bool = Field(None, serialization_alias="lineMetrics")
    -    maxzoom: int = None
    -    promote_id: Union[str, dict] = Field(None, serialization_alias="promoteId")
    -    tolerance: float = None
    -
    -    @computed_field
    -    @property
    -    def type(self) -> str:
    -        return SourceType.GEOJSON.value
    -
    -
    - - - -
    - - - - - - - - - - - -
    - -
    - -
    - -
    - - - - -

    - SourceType - - -

    - - -
    -

    - Bases: Enum

    - - -

    Source types

    - -
    - Source code in pymaplibregl/sources.py -
    11
    -12
    -13
    -14
    -15
    -16
    -17
    -18
    -19
    class SourceType(Enum):
    -    """Source types"""
    -
    -    RASTER = "raster"
    -    VECTOR = "vector"
    -    RASTER_DEM = "raster-dem"
    -    GEOJSON = "geojson"
    -    IMAGE = "image"
    -    VIDEO = "video"
    -
    -
    - - - -
    - - - - - - - - - - - -
    - -
    - -
    - - - - -
    - -
    - -
    +

    Pymaplibregl

    +

    Pymaplibregl provides Python bindings for maplibre-gl-js.

    +

    It integrates seamlessly into py-shiny.

    +

    Installation

    +
    # Stable
    +pip install git+https://github.com/eodaGmbH/py-maplibregl
    +
    +# Dev
    +pip install git+https://github.com/eodaGmbH/py-maplibregl@dev
    +
    +

    Basic usage

    +

    Standalone

    +
    import webbrowser
    +
    +from pymaplibregl import Layer, LayerType, Map, MapOptions
    +from pymaplibregl.sources import GeoJSONSource
    +
    +vancouver_blocks = GeoJSONSource(
    +    data="https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/geojson/vancouver-blocks.json",
    +)
    +
    +map_options = MapOptions(center=(-123.1256, 49.24658), zoom=12, hash=True, pitch=35)
    +
    +m = Map(map_options)
    +m.add_layer(
    +    Layer(
    +        type=LayerType.LINE,
    +        source=vancouver_blocks,
    +        paint={"line-color": "white"},
    +    )
    +)
    +
    +temp_file = "/tmp/pymaplibregl.html"
    +
    +with open(temp_file, "w") as f:
    +    f.write(m.to_html(style="height: 800px;"))
    +
    +webbrowser.open(temp_file)
    +
    +

    Shiny integration

    +
    from pymaplibregl import Map, MapContext, output_maplibregl, render_maplibregl
    +from pymaplibregl.controls import Marker
    +from shiny import App, reactive, ui
    +
    +app_ui = ui.page_fluid(
    +    output_maplibregl("maplibre", height=600),
    +)
    +
    +
    +def server(input, output, session):
    +    @render_maplibregl
    +    def maplibre():
    +        m = Map()
    +        return m
    +
    +    @reactive.Effect
    +    @reactive.event(input.maplibre)
    +    async def coords():
    +        async with MapContext("maplibre") as m:
    +            print(input.maplibre())
    +            m.add_marker(Marker(lng_lat=input.maplibre()["coords"].values()))
    +
    +
    +app = App(app_ui, server)
    +
    +if __name__ == "__main__":
    +    app.run()
    +
    @@ -2814,7 +922,7 @@

    - + diff --git a/objects.inv b/objects.inv index 87d590497dfe264efa45528813bfc5eef10b4ad9..fb06cad0bde205c9ce740bb93ecfd7e533ef81d7 100644 GIT binary patch delta 395 zcmV;60d)TO0{jDzC;?EBDOP`-mdkE~Fc3xe{R*UZTcT#!EmA90O%o~IBL|!o)!>mI z3;w=56R^z~vjaTm44B~xs7nH@xCr{g;!jdj5kdW$F(PI35)mkNti8B*0JHaH=wa91?CaFrV z1yh0d*ka9waII1h9H>xrFb|}tHsXq>zp4y+hev3uZ>ee{kZm=$^=EyGHS*8Izfyv`X${9x6H9W_BC7u+?h>r*ZB#f#Hq2 zkJ?PA{WNgwbV3~S;PQWXx?;oC9L^JMf1gq-_T21Z$RVm3gJ|sx^hud($EHe0K>C~m zf=KQ7^f`M1Q982K=Nym)=|b{i(g}h{v0V1qO%`c`#J8`Dfi5(0g*;{+>)kpl8xYl4 pYnb}?X=nRz-4QRtO8idw$NBhmzRl1yp8R;vx&De~>_4XGXHo%LzeWH6 delta 262 zcmV+h0r~#?1NZ`vC;@PhDOP`#lS^;IAP|J_{S`>bHAw9-*Bl~Mc}eNrBKD@Tg1svq z2mXB^v7NNC%=!l6n}HdCLZe967X!aqUX+D6wSvOB!OCk8pJK5Ts}CB(Pymaplibregl provides Python bindings for maplibre-gl-js.

    It integrates seamlessly into py-shiny.

    "},{"location":"#installation","title":"Installation","text":"
    # Stable\npip install git+https://github.com/eodaGmbH/py-maplibregl\n\n# Dev\npip install git+https://github.com/eodaGmbH/py-maplibregl@dev\n
    "},{"location":"#basic-usage","title":"Basic usage","text":""},{"location":"#standalone","title":"Standalone","text":"
    import webbrowser\n\nfrom pymaplibregl import Layer, LayerType, Map, MapOptions\nfrom pymaplibregl.sources import GeoJSONSource\n\nvancouver_blocks = GeoJSONSource(\n    data=\"https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/geojson/vancouver-blocks.json\",\n)\n\nmap_options = MapOptions(center=(-123.1256, 49.24658), zoom=12, hash=True, pitch=35)\n\nm = Map(map_options)\nm.add_layer(\n    Layer(\n        type=LayerType.LINE,\n        source=vancouver_blocks,\n        paint={\"line-color\": \"white\"},\n    )\n)\n\ntemp_file = \"/tmp/pymaplibregl.html\"\n\nwith open(temp_file, \"w\") as f:\n    f.write(m.to_html(style=\"height: 800px;\"))\n\nwebbrowser.open(temp_file)\n
    "},{"location":"#shiny-integration","title":"Shiny integration","text":"
    from pymaplibregl import Map, MapContext, output_maplibregl, render_maplibregl\nfrom pymaplibregl.controls import Marker\nfrom shiny import App, reactive, ui\n\napp_ui = ui.page_fluid(\n    output_maplibregl(\"maplibre\", height=600),\n)\n\n\ndef server(input, output, session):\n    @render_maplibregl\n    def maplibre():\n        m = Map()\n        return m\n\n    @reactive.Effect\n    @reactive.event(input.maplibre)\n    async def coords():\n        async with MapContext(\"maplibre\") as m:\n            print(input.maplibre())\n            m.add_marker(Marker(lng_lat=input.maplibre()[\"coords\"].values()))\n\n\napp = App(app_ui, server)\n\nif __name__ == \"__main__\":\n    app.run()\n
    "},{"location":"api/basemaps/","title":"Basemaps","text":""},{"location":"api/basemaps/#pymaplibregl.basemaps.Carto","title":"pymaplibregl.basemaps.Carto","text":"

    Bases: Enum

    Carto basemap styles

    Attributes:

    • DARK_MATTER \u2013

      dark-matter

    • POSITRON \u2013

      positron

    • VOYAGER \u2013

      voyager

    • POSITRON_NOLABELS \u2013

      positron-nolabels

    • DARK_MATTER_NOLABELS \u2013

      dark-matter-nolabels

    • VOYAGER_NOLABELS \u2013

      voyager-nolabels

    Examples:

    >>> from pymaplibregl import Map, MapOptions\n>>> from pymaplibregl.basemaps import Carto\n
    >>> map = Map(MapOptions(style=Carto.DARK_MATTER))\n
    Source code in pymaplibregl/basemaps.py
    class Carto(Enum):\n    \"\"\"Carto basemap styles\n\n    Attributes:\n        DARK_MATTER: dark-matter\n        POSITRON: positron\n        VOYAGER: voyager\n        POSITRON_NOLABELS: positron-nolabels\n        DARK_MATTER_NOLABELS: dark-matter-nolabels\n        VOYAGER_NOLABELS: voyager-nolabels\n\n    Examples:\n        >>> from pymaplibregl import Map, MapOptions\n        >>> from pymaplibregl.basemaps import Carto\n\n        >>> map = Map(MapOptions(style=Carto.DARK_MATTER))\n    \"\"\"\n\n    DARK_MATTER = \"dark-matter\"\n    POSITRON = \"positron\"\n    VOYAGER = \"voyager\"\n    POSITRON_NOLABELS = \"positron-nolabels\"\n    DARK_MATTER_NOLABELS = \"dark-matter-nolabels\"\n    VOYAGER_NOLABELS = \"voyager-nolabels\"\n
    "},{"location":"api/controls/","title":"Markers and controls","text":""},{"location":"api/controls/#pymaplibregl.controls","title":"pymaplibregl.controls","text":"

    Markers and controls

    See also https://docs.mapbox.com/mapbox-gl-js/api/markers/

    "},{"location":"api/controls/#pymaplibregl.controls.ControlPosition","title":"ControlPosition","text":"

    Bases: Enum

    Control position

    Source code in pymaplibregl/controls.py
    class ControlPosition(Enum):\n    \"\"\"Control position\"\"\"\n\n    TOP_LEFT = \"top-left\"\n    TOP_RIGHT = \"top-right\"\n    BOTTOM_LEFT = \"bottom-left\"\n    BOTTOM_RIGHT = \"bottom-right\"\n
    "},{"location":"api/controls/#pymaplibregl.controls.FullscreenControl","title":"FullscreenControl","text":"

    Bases: Control

    Fullscreen control

    Examples:

    >>> from pymaplibregl import Map\n>>> from pymaplibregl.controls import FullscreenControl\n
    >>> map = Map()\n>>> map.add_control(FullscreenControl())\n
    Source code in pymaplibregl/controls.py
    class FullscreenControl(Control):\n    \"\"\"Fullscreen control\n\n    Examples:\n        >>> from pymaplibregl import Map\n        >>> from pymaplibregl.controls import FullscreenControl\n\n        >>> map = Map()\n        >>> map.add_control(FullscreenControl())\n    \"\"\"\n\n    # _name: str = ControlType.FULLSCREEN.value\n    pass\n
    "},{"location":"api/controls/#pymaplibregl.controls.Marker","title":"Marker","text":"

    Bases: BaseModel

    Marker

    Attributes:

    Name Type Description lng_lat (tuple, list)

    Required. The longitude and latitude of the marker.

    popup (Popup, dict)

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

    options (MarkerOptions, dict)

    Marker options.

    Source code in pymaplibregl/controls.py
    class Marker(BaseModel):\n    \"\"\"Marker\n\n    Attributes:\n        lng_lat (tuple, list): **Required.** The longitude and latitude of the marker.\n        popup (Popup, dict): A Popup that is displayed when a user clicks on the marker.\n        options (MarkerOptions, dict): Marker options.\n    \"\"\"\n\n    lng_lat: Union[tuple, list] = Field(None, serialization_alias=\"lngLat\")\n    popup: Union[Popup, dict] = None\n    options: Union[MarkerOptions, dict] = {}\n
    "},{"location":"api/controls/#pymaplibregl.controls.MarkerOptions","title":"MarkerOptions","text":"

    Bases: BaseModel

    Marker options

    Source code in pymaplibregl/controls.py
    class MarkerOptions(BaseModel):\n    \"\"\"Marker options\"\"\"\n\n    anchor: str = None\n    color: str = None\n    draggable: bool = None\n    offset: Union[tuple, list] = None\n    pitch_alignment: str = Field(None, serialization_alias=\"pitchAlignment\")\n    rotation: int = None\n    rotation_alignment: str = Field(None, serialization_alias=\"rotationAlignment\")\n    scale: int = None\n
    "},{"location":"api/controls/#pymaplibregl.controls.Popup","title":"Popup","text":"

    Bases: BaseModel

    Popup

    Attributes:

    Name Type Description text str

    The Text of the popup.

    options PopupOptions | dict

    Popup options.

    Source code in pymaplibregl/controls.py
    class Popup(BaseModel):\n    \"\"\"Popup\n\n    Attributes:\n        text: The Text of the popup.\n        options (PopupOptions | dict): Popup options.\n    \"\"\"\n\n    text: str\n    options: Union[PopupOptions, dict] = {}\n
    "},{"location":"api/controls/#pymaplibregl.controls.PopupOptions","title":"PopupOptions","text":"

    Bases: BaseModel

    Popup options

    Source code in pymaplibregl/controls.py
    class PopupOptions(BaseModel):\n    \"\"\"Popup options\"\"\"\n\n    anchor: str = None\n    close_button: bool = Field(False, serialization_alias=\"closeButton\")\n    close_on_click: bool = Field(None, serialization_alias=\"closeOnClick\")\n    close_on_move: bool = Field(None, serialization_alias=\"closeOnMove\")\n    max_width: int = Field(None, serialization_alias=\"maxWidth\")\n    offset: Union[int, list, dict] = None\n
    "},{"location":"api/layer/","title":"Layer","text":""},{"location":"api/layer/#pymaplibregl.Layer","title":"pymaplibregl.Layer","text":"

    Bases: BaseModel

    Layer properties

    Notes

    See layers for more details.

    Attributes:

    Name Type Description id str

    Required. The unique ID of the layer. Defaults to str(uuid4()).

    type str | LayerType

    Required. The type of the layer.

    filter list

    The filter expression that is applied to the source of the layer.

    layout dict

    The layout properties of the layer.

    max_zoom int

    The maximum zoom level for the layer.

    min_zoom int

    The minimum zoom level for the layer.

    paint dict

    The paint properties of the layer.

    source str | Source

    The name (unique ID) of a source or a source object to be used for the layer.

    source_layer str

    The layer to use from a vector tile source.

    Examples:

    >>> from pymaplibregl.layer import Layer, LayerType\n
    >>> layer = Layer(id=\"test-layer\", type=LayerType.CIRCLE, source=\"test-source\")\n
    Source code in pymaplibregl/layer.py
    class Layer(BaseModel):\n    \"\"\"Layer properties\n\n    Notes:\n        See [layers](https://maplibre.org/maplibre-style-spec/layers/) for more details.\n\n    Attributes:\n        id (str): **Required.** The unique ID of the layer. Defaults to `str(uuid4())`.\n        type (str | LayerType): **Required.** The type of the layer.\n        filter (list): The filter expression that is applied to the source of the layer.\n        layout (dict): The layout properties of the layer.\n        max_zoom (int): The maximum zoom level for the layer.\n        min_zoom (int): The minimum zoom level for the layer.\n        paint (dict): The paint properties of the layer.\n        source (str | Source): The name (unique ID) of a source or a source object to be used for the layer.\n        source_layer (str): The layer to use from a vector tile source.\n\n    Examples:\n        >>> from pymaplibregl.layer import Layer, LayerType\n\n        >>> layer = Layer(id=\"test-layer\", type=LayerType.CIRCLE, source=\"test-source\")\n    \"\"\"\n\n    id: str = str(uuid4())\n    type: LayerType\n    filter: list = None\n    layout: dict = None\n    max_zoom: int = Field(None, serialization_alias=\"maxzoom\")\n    metadata: dict = None\n    min_zoom: int = Field(None, serialization_alias=\"minzoom\")\n    paint: dict = None\n    source: Union[str, Source, dict, None] = None\n    source_layer: str = Field(None, serialization_alias=\"source-layer\")\n\n    @field_validator(\"source\")\n    def validate_source(cls, v):\n        if isinstance(v, Source):\n            return v.to_dict()\n\n        return v\n\n    @field_validator(\"paint\", \"layout\")\n    def fix_paint(cls, v):\n        if isinstance(v, dict):\n            return fix_keys(v)\n\n        return v\n
    "},{"location":"api/layer/#pymaplibregl.LayerType","title":"pymaplibregl.LayerType","text":"

    Bases: Enum

    Rendering type of layer

    Attributes:

    • CIRCLE \u2013

      A filled circle.

    • FILL \u2013

      A filled polygon with an optional stroked border.

    • FILL_EXTRUSION \u2013

      An extruded polygon.

    • LINE \u2013

      A stroked line.

    • SYMBOL \u2013

      An icon or a text label.

    • RASTER \u2013

      Raster map textures such as satellite imagery.

    • HEATMAP \u2013

      A heatmap.

    • HILLSHADE \u2013

      A Client-side hillshading visualization based on DEM data.

    • BACKGROUND \u2013

      A background color or pattern.

    Source code in pymaplibregl/layer.py
    class LayerType(Enum):\n    \"\"\"Rendering type of layer\n\n    Attributes:\n        CIRCLE: A filled circle.\n        FILL: A filled polygon with an optional stroked border.\n        FILL_EXTRUSION: An extruded polygon.\n        LINE: A stroked line.\n        SYMBOL: An icon or a text label.\n        RASTER: Raster map textures such as satellite imagery.\n        HEATMAP: A heatmap.\n        HILLSHADE: A Client-side hillshading visualization based on DEM data.\n        BACKGROUND: A background color or pattern.\n    \"\"\"\n\n    CIRCLE = \"circle\"\n    FILL = \"fill\"\n    FILL_EXTRUSION = \"fill-extrusion\"\n    LINE = \"line\"\n    SYMBOL = \"symbol\"\n    RASTER = \"raster\"\n    HEATMAP = \"heatmap\"\n    HILLSHADE = \"hillshade\"\n    BACKGROUND = \"background\"\n
    "},{"location":"api/map/","title":"Map","text":""},{"location":"api/map/#pymaplibregl.Map","title":"pymaplibregl.Map","text":"

    Bases: object

    Map

    Parameters:

    Name Type Description Default map_options MapOptions

    Map options.

    MapOptions() **kwargs

    Keyword arguments that are appended to the MapOptions object.

    {}

    Examples:

    >>> from pymaplibregl.map import Map, MapOptions\n
    >>> map_options = MapOptions(center=(9.5, 51.31667), zoom=8)\n>>> map = Map(map_options)\n>>> dict(map)\n{'mapOptions': {'center': (9.5, 51.31667), 'style': 'https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json', 'zoom': 8}, 'calls': []}\n
    Source code in pymaplibregl/map.py
    class Map(object):\n    \"\"\"Map\n\n    Args:\n        map_options (MapOptions): Map options.\n        **kwargs: Keyword arguments that are appended to the `MapOptions` object.\n\n    Examples:\n        >>> from pymaplibregl.map import Map, MapOptions\n\n        >>> map_options = MapOptions(center=(9.5, 51.31667), zoom=8)\n        >>> map = Map(map_options)\n        >>> dict(map)\n        {'mapOptions': {'center': (9.5, 51.31667), 'style': 'https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json', 'zoom': 8}, 'calls': []}\n    \"\"\"\n\n    MESSAGE = \"not implemented yet\"\n\n    def __init__(self, map_options: MapOptions = MapOptions(), **kwargs):\n        self._map_options = map_options.to_dict() | kwargs\n        self._calls = []\n\n    def __iter__(self):\n        for k, v in self.to_dict().items():\n            yield k, v\n\n    def to_dict(self) -> dict:\n        return {\"mapOptions\": self._map_options, \"calls\": self._calls}\n\n    @property\n    def sources(self) -> list:\n        return [item[\"data\"] for item in self._calls if item[\"name\"] == \"addSource\"]\n\n    @property\n    def layers(self) -> list:\n        return [item[\"data\"] for item in self._calls if item[\"name\"] == \"addLayer\"]\n\n    # TODO: Rename to add_map_call\n    def add_call(self, func_name: str, params: list) -> None:\n        self._calls.append(\n            {\"name\": \"applyFunc\", \"data\": {\"funcName\": func_name, \"params\": params}}\n        )\n\n    def add_control(\n        self,\n        control: Control,\n        position: [str | ControlPosition] = ControlPosition.TOP_RIGHT,\n    ) -> None:\n        \"\"\"Add a control to the map\n\n        Args:\n            control (Control): The control to be add to the map.\n            position (str | ControlPosition): The position of the control.\n        \"\"\"\n        data = {\n            \"type\": control.type,\n            \"options\": control.to_dict(),\n            \"position\": ControlPosition(position).value,\n        }\n        self._calls.append({\"name\": \"addControl\", \"data\": data})\n\n    def add_source(self, id: str, source: [Source | dict]) -> None:\n        \"\"\"Add a source to the map\"\"\"\n        if isinstance(source, Source):\n            source = source.to_dict()\n\n        self._calls.append({\"name\": \"addSource\", \"data\": {\"id\": id, \"source\": source}})\n\n    def add_layer(self, layer: [Layer | dict]) -> None:\n        \"\"\"Add a layer to the map\n\n        Args:\n            layer (Layer | dict): The Layer to be added to the map.\n        \"\"\"\n        if isinstance(layer, Layer):\n            layer = layer.to_dict()\n\n        self._calls.append({\"name\": \"addLayer\", \"data\": layer})\n\n    def add_marker(self, marker: Marker) -> None:\n        \"\"\"Add a marker to the map\n\n        Args:\n            marker (Marker): The marker to be added to the map.\n        \"\"\"\n        self._calls.append({\"name\": \"addMarker\", \"data\": marker.to_dict()})\n\n    def add_popup(self, layer_id: str, prop: str) -> None:\n        \"\"\"Add a popup to the map\"\"\"\n        self._calls.append(\n            {\"name\": \"addPopup\", \"data\": {\"layerId\": layer_id, \"property\": prop}}\n        )\n\n    def set_filter(self, layer_id: str, filter_: list):\n        \"\"\"Update the filter of a layer\n\n        Args:\n            layer_id (str): The name of the layer to be updated.\n            filter_ (list): The filter expression that is applied to the source of the layer.\n        \"\"\"\n        self.add_call(\"setFilter\", [layer_id, filter_])\n\n    def set_paint_property(self, layer_id: str, prop: str, value: any) -> None:\n        \"\"\"Update the paint property of a layer\n\n        Args:\n            layer_id (str): The name of the layer to be updated.\n            prop (str): The name of the paint property to be updated.\n            value (any): The new value of the paint property.\n        \"\"\"\n        self.add_call(\"setPaintProperty\", [layer_id, prop, value])\n\n    def set_layout_property(self, layer_id: str, prop: str, value: any) -> None:\n        \"\"\"Update a layout property of a layer\n\n        Args:\n            layer_id (str): The name of the layer to be updated.\n            prop (str): The name of the layout property to be updated.\n            value (any): The new value of the layout property.\n        \"\"\"\n        self.add_call(\"setLayoutProperty\", [layer_id, prop, value])\n\n    def to_html(self, **kwargs) -> str:\n        \"\"\"Render to html\n\n        Args:\n            **kwargs (Any): Additional keyword arguments that are passed to the template.\n                Currently, `style` is the only supported keyword argument.\n\n        Examples:\n            >>> from pymaplibregl import Map\n\n            >>> map = Map()\n            >>> with open(\"/tmp/map.html\", \"w\") as f:\n            ...     f.write(map.to_html(style=\"height: 800px;\")\n        \"\"\"\n        js_lib = read_internal_file(\"srcjs\", \"index.js\")\n        js_snippet = Template(js_template).render(data=json.dumps(self.to_dict()))\n        output = Template(html_template).render(\n            js=\"\\n\".join([js_lib, js_snippet]), **kwargs\n        )\n        return output\n
    "},{"location":"api/map/#pymaplibregl.Map.add_control","title":"add_control(control, position=ControlPosition.TOP_RIGHT)","text":"

    Add a control to the map

    Parameters:

    Name Type Description Default control Control

    The control to be add to the map.

    required position str | ControlPosition

    The position of the control.

    TOP_RIGHT Source code in pymaplibregl/map.py
    def add_control(\n    self,\n    control: Control,\n    position: [str | ControlPosition] = ControlPosition.TOP_RIGHT,\n) -> None:\n    \"\"\"Add a control to the map\n\n    Args:\n        control (Control): The control to be add to the map.\n        position (str | ControlPosition): The position of the control.\n    \"\"\"\n    data = {\n        \"type\": control.type,\n        \"options\": control.to_dict(),\n        \"position\": ControlPosition(position).value,\n    }\n    self._calls.append({\"name\": \"addControl\", \"data\": data})\n
    "},{"location":"api/map/#pymaplibregl.Map.add_layer","title":"add_layer(layer)","text":"

    Add a layer to the map

    Parameters:

    Name Type Description Default layer Layer | dict

    The Layer to be added to the map.

    required Source code in pymaplibregl/map.py
    def add_layer(self, layer: [Layer | dict]) -> None:\n    \"\"\"Add a layer to the map\n\n    Args:\n        layer (Layer | dict): The Layer to be added to the map.\n    \"\"\"\n    if isinstance(layer, Layer):\n        layer = layer.to_dict()\n\n    self._calls.append({\"name\": \"addLayer\", \"data\": layer})\n
    "},{"location":"api/map/#pymaplibregl.Map.add_marker","title":"add_marker(marker)","text":"

    Add a marker to the map

    Parameters:

    Name Type Description Default marker Marker

    The marker to be added to the map.

    required Source code in pymaplibregl/map.py
    def add_marker(self, marker: Marker) -> None:\n    \"\"\"Add a marker to the map\n\n    Args:\n        marker (Marker): The marker to be added to the map.\n    \"\"\"\n    self._calls.append({\"name\": \"addMarker\", \"data\": marker.to_dict()})\n
    "},{"location":"api/map/#pymaplibregl.Map.add_popup","title":"add_popup(layer_id, prop)","text":"

    Add a popup to the map

    Source code in pymaplibregl/map.py
    def add_popup(self, layer_id: str, prop: str) -> None:\n    \"\"\"Add a popup to the map\"\"\"\n    self._calls.append(\n        {\"name\": \"addPopup\", \"data\": {\"layerId\": layer_id, \"property\": prop}}\n    )\n
    "},{"location":"api/map/#pymaplibregl.Map.add_source","title":"add_source(id, source)","text":"

    Add a source to the map

    Source code in pymaplibregl/map.py
    def add_source(self, id: str, source: [Source | dict]) -> None:\n    \"\"\"Add a source to the map\"\"\"\n    if isinstance(source, Source):\n        source = source.to_dict()\n\n    self._calls.append({\"name\": \"addSource\", \"data\": {\"id\": id, \"source\": source}})\n
    "},{"location":"api/map/#pymaplibregl.Map.set_filter","title":"set_filter(layer_id, filter_)","text":"

    Update the filter of a layer

    Parameters:

    Name Type Description Default layer_id str

    The name of the layer to be updated.

    required filter_ list

    The filter expression that is applied to the source of the layer.

    required Source code in pymaplibregl/map.py
    def set_filter(self, layer_id: str, filter_: list):\n    \"\"\"Update the filter of a layer\n\n    Args:\n        layer_id (str): The name of the layer to be updated.\n        filter_ (list): The filter expression that is applied to the source of the layer.\n    \"\"\"\n    self.add_call(\"setFilter\", [layer_id, filter_])\n
    "},{"location":"api/map/#pymaplibregl.Map.set_layout_property","title":"set_layout_property(layer_id, prop, value)","text":"

    Update a layout property of a layer

    Parameters:

    Name Type Description Default layer_id str

    The name of the layer to be updated.

    required prop str

    The name of the layout property to be updated.

    required value any

    The new value of the layout property.

    required Source code in pymaplibregl/map.py
    def set_layout_property(self, layer_id: str, prop: str, value: any) -> None:\n    \"\"\"Update a layout property of a layer\n\n    Args:\n        layer_id (str): The name of the layer to be updated.\n        prop (str): The name of the layout property to be updated.\n        value (any): The new value of the layout property.\n    \"\"\"\n    self.add_call(\"setLayoutProperty\", [layer_id, prop, value])\n
    "},{"location":"api/map/#pymaplibregl.Map.set_paint_property","title":"set_paint_property(layer_id, prop, value)","text":"

    Update the paint property of a layer

    Parameters:

    Name Type Description Default layer_id str

    The name of the layer to be updated.

    required prop str

    The name of the paint property to be updated.

    required value any

    The new value of the paint property.

    required Source code in pymaplibregl/map.py
    def set_paint_property(self, layer_id: str, prop: str, value: any) -> None:\n    \"\"\"Update the paint property of a layer\n\n    Args:\n        layer_id (str): The name of the layer to be updated.\n        prop (str): The name of the paint property to be updated.\n        value (any): The new value of the paint property.\n    \"\"\"\n    self.add_call(\"setPaintProperty\", [layer_id, prop, value])\n
    "},{"location":"api/map/#pymaplibregl.Map.to_html","title":"to_html(**kwargs)","text":"

    Render to html

    Parameters:

    Name Type Description Default **kwargs Any

    Additional keyword arguments that are passed to the template. Currently, style is the only supported keyword argument.

    {}

    Examples:

    >>> from pymaplibregl import Map\n
    >>> map = Map()\n>>> with open(\"/tmp/map.html\", \"w\") as f:\n...     f.write(map.to_html(style=\"height: 800px;\")\n
    Source code in pymaplibregl/map.py
    def to_html(self, **kwargs) -> str:\n    \"\"\"Render to html\n\n    Args:\n        **kwargs (Any): Additional keyword arguments that are passed to the template.\n            Currently, `style` is the only supported keyword argument.\n\n    Examples:\n        >>> from pymaplibregl import Map\n\n        >>> map = Map()\n        >>> with open(\"/tmp/map.html\", \"w\") as f:\n        ...     f.write(map.to_html(style=\"height: 800px;\")\n    \"\"\"\n    js_lib = read_internal_file(\"srcjs\", \"index.js\")\n    js_snippet = Template(js_template).render(data=json.dumps(self.to_dict()))\n    output = Template(html_template).render(\n        js=\"\\n\".join([js_lib, js_snippet]), **kwargs\n    )\n    return output\n
    "},{"location":"api/map/#pymaplibregl.MapOptions","title":"pymaplibregl.MapOptions","text":"

    Bases: BaseModel

    Map options

    Note

    See mapOptions for more details.

    Source code in pymaplibregl/map.py
    class MapOptions(BaseModel):\n    \"\"\"Map options\n\n    Note:\n        See [mapOptions](https://maplibre.org/maplibre-gl-js/docs/API/types/maplibregl.MapOptions/) for more details.\n    \"\"\"\n\n    model_config = ConfigDict(\n        validate_assignment=True, extra=\"forbid\", use_enum_values=False\n    )\n    antialias: bool = None\n    attribution_control: bool = Field(None, serialization_alias=\"attributionControl\")\n    bearing: int = None\n    bearing_snap: int = Field(None, serialization_alias=\"bearingSnap\")\n    bounds: tuple = None\n    box_zoom: bool = Field(None, serialization_alias=\"boxZoom\")\n    center: tuple = None\n    click_tolerance: int = Field(None, serialization_alias=\"clickTolerance\")\n    custom_attribution: bool = Field(None, serialization_alias=\"customAttribution\")\n    double_click_zoom: bool = Field(None, serialization_alias=\"doubleClickZoom\")\n    fade_duration: int = Field(None, serialization_alias=\"fadeDuration\")\n    fit_bounds_options: dict = Field(None, serialization_alias=\"fitBoundsOptions\")\n    hash: Union[bool, str] = None\n    interactive: bool = None\n    keyword: bool = None\n    max_bounds: tuple = Field(None, serialization_alias=\"maxBounds\")\n    max_pitch: int = Field(None, serialization_alias=\"maxPitch\")\n    max_zoom: int = Field(None, serialization_alias=\"maxZoom\")\n    min_pitch: int = Field(None, serialization_alias=\"minPitch\")\n    min_zoom: int = Field(None, serialization_alias=\"minZoom\")\n    pitch: int = None\n    scroll_zoom: bool = Field(None, serialization_alias=\"scrollZoom\")\n    style: Union[str, Carto] = construct_carto_basemap_url(Carto.DARK_MATTER)\n    zoom: int = None\n\n    @field_validator(\"style\")\n    def validate_style(cls, v):\n        if isinstance(v, Carto):\n            return construct_carto_basemap_url(v)\n\n        return v\n
    "},{"location":"api/sources/","title":"Sources","text":""},{"location":"api/sources/#pymaplibregl.sources","title":"pymaplibregl.sources","text":""},{"location":"api/sources/#pymaplibregl.sources.GeoJSONSource","title":"GeoJSONSource","text":"

    Bases: Source

    GeoJSON Source

    Examples:

    >>> from pymaplibregl.sources import GeoJSONSource\n
    >>> source = GeoJSONSource(data=\"https://docs.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson\")\n
    Source code in pymaplibregl/sources.py
    class GeoJSONSource(Source):\n    \"\"\"GeoJSON Source\n\n    Examples:\n        >>> from pymaplibregl.sources import GeoJSONSource\n\n        >>> source = GeoJSONSource(data=\"https://docs.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson\")\n    \"\"\"\n\n    data: Union[str, dict]\n    attribution: str = None\n    buffer: int = None\n    cluster: bool = None\n    cluster_max_zoom: int = Field(None, serialization_alias=\"clusterMaxZoom\")\n    cluster_min_points: int = Field(None, serialization_alias=\"clusterMinPoints\")\n    cluster_properties: dict = Field(None, serialization_alias=\"clusterProperties\")\n    cluster_radius: int = Field(None, serialization_alias=\"clusterRadius\")\n    filter: list = None\n    generate_id: bool = Field(None, serialization_alias=\"generateId\")\n    line_metrics: bool = Field(None, serialization_alias=\"lineMetrics\")\n    maxzoom: int = None\n    promote_id: Union[str, dict] = Field(None, serialization_alias=\"promoteId\")\n    tolerance: float = None\n\n    @computed_field\n    @property\n    def type(self) -> str:\n        return SourceType.GEOJSON.value\n
    "},{"location":"api/sources/#pymaplibregl.sources.SourceType","title":"SourceType","text":"

    Bases: Enum

    Source types

    Source code in pymaplibregl/sources.py
    class SourceType(Enum):\n    \"\"\"Source types\"\"\"\n\n    RASTER = \"raster\"\n    VECTOR = \"vector\"\n    RASTER_DEM = \"raster-dem\"\n    GEOJSON = \"geojson\"\n    IMAGE = \"image\"\n    VIDEO = \"video\"\n
    "},{"location":"examples/airports/","title":"Airport markers","text":"
    import pandas as pd\nfrom pymaplibregl import (\n    Layer,\n    LayerType,\n    Map,\n    MapOptions,\n    output_maplibregl,\n    render_maplibregl,\n)\nfrom pymaplibregl.basemaps import Carto\nfrom pymaplibregl.controls import Marker, MarkerOptions, Popup, PopupOptions\nfrom pymaplibregl.sources import GeoJSONSource\nfrom pymaplibregl.utils import GeometryType, df_to_geojson\nfrom shiny import App, ui\n\nBOUNDS = (-8.92242886, 43.30508298, 13.76496714, 59.87668996)\n\nairports_data = pd.read_json(\n    \"https://github.com/visgl/deck.gl-data/raw/master/examples/line/airports.json\"\n)\n\n\ndef get_color(airport_type: str) -> str:\n    color = \"darkblue\"\n    if airport_type == \"mid\":\n        color = \"darkred\"\n    elif airport_type == \"major\":\n        color = \"darkgreen\"\n\n    return color\n\n\ngeojson = df_to_geojson(\n    airports_data,\n    \"coordinates\",\n    GeometryType.POINT,\n    properties=[\"type\", \"name\", \"abbrev\"],\n)\n\nairport_circles = Layer(\n    type=LayerType.CIRCLE,\n    source=GeoJSONSource(data=geojson),\n    paint={\n        \"circle-color\": [\n            \"match\",\n            [\"get\", \"type\"],\n            \"mid\",\n            \"darkred\",\n            \"major\",\n            \"darkgreen\",\n            \"darkblue\",\n        ],\n        \"circle_radius\": 10,\n        \"circle-opacity\": 0.3,\n    },\n)\n\nmap_options = MapOptions(\n    style=Carto.POSITRON,\n    bounds=BOUNDS,\n    fit_bounds_options={\"padding\": 20},\n    hash=True,\n)\n\npopup_options = PopupOptions(close_button=False)\n\napp_ui = ui.page_fluid(\n    ui.panel_title(\"Airports\"),\n    output_maplibregl(\"maplibre\", height=600),\n)\n\n\ndef server(input, output, session):\n    @render_maplibregl\n    async def maplibre():\n        m = Map(map_options)\n        for _, r in airports_data.iterrows():\n            marker = Marker(\n                lng_lat=r[\"coordinates\"],\n                options=MarkerOptions(color=get_color(r[\"type\"])),\n                popup=Popup(\n                    text=r[\"name\"],\n                    options=popup_options,\n                ),\n            )\n            m.add_marker(marker)\n        m.add_layer(airport_circles)\n        return m\n\n\napp = App(app_ui, server)\n\nif __name__ == \"__main__\":\n    app.run()\n

    Run example:

    poetry run uvicorn docs.examples.airports.app:app --reload\n
    "},{"location":"examples/earthquake_clusters/","title":"Earthquake clusters","text":"
    from pymaplibregl import (\n    Layer,\n    LayerType,\n    Map,\n    MapOptions,\n    output_maplibregl,\n    render_maplibregl,\n)\nfrom pymaplibregl.basemaps import Carto\nfrom pymaplibregl.sources import GeoJSONSource\nfrom shiny import App, reactive, ui\n\nEARTHQUAKE_SOURCE = \"earthquakes\"\nEARTHQUAKE_CIRCLES = \"earthquake-circles\"\nEARTHQUAKE_CLUSTERS = \"earthquake-clusters\"\nEARTHQUAKE_LABELS = \"earthquake-labels\"\n\nCENTER = (-118.0931, 33.78615)\n\nearthquakes_source = GeoJSONSource(\n    data=\"https://docs.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson\",\n    cluster=True,\n    cluster_radius=50,\n    cluster_min_points=2,\n    cluster_max_zoom=14,\n    cluster_properties={\n        \"maxMag\": [\"max\", [\"get\", \"mag\"]],\n        \"minMag\": [\"min\", [\"get\", \"mag\"]],\n    },\n)\n\nearthquake_circles = Layer(\n    type=LayerType.CIRCLE,\n    id=EARTHQUAKE_CIRCLES,\n    source=EARTHQUAKE_SOURCE,\n    paint={\"circle-color\": \"darkblue\"},\n    filter=[\"!\", [\"has\", \"point_count\"]],\n)\n\nearthquake_clusters = Layer(\n    type=LayerType.CIRCLE,\n    id=EARTHQUAKE_CLUSTERS,\n    source=EARTHQUAKE_SOURCE,\n    filter=[\"has\", \"point_count\"],\n    paint={\n        \"circle-color\": [\n            \"step\",\n            [\"get\", \"point_count\"],\n            \"#51bbd6\",\n            100,\n            \"#f1f075\",\n            750,\n            \"#f28cb1\",\n        ],\n        \"circle-radius\": [\"step\", [\"get\", \"point_count\"], 20, 100, 30, 750, 40],\n    },\n)\n\nearthquake_labels = Layer(\n    type=LayerType.SYMBOL,\n    id=\"text\",\n    source=EARTHQUAKE_SOURCE,\n    filter=[\"has\", \"point_count\"],\n    layout={\n        \"text-field\": [\"get\", \"point_count_abbreviated\"],\n        \"text-size\": 12,\n    },\n)\n\nmap_options = MapOptions(style=Carto.POSITRON, center=CENTER, zoom=3, hash=True)\n\napp_ui = ui.page_fluid(\n    ui.panel_title(\"Earthquakes Cluster\"),\n    output_maplibregl(\"maplibre\", height=500),\n)\n\n\ndef server(input, output, session):\n    @render_maplibregl\n    async def maplibre():\n        m = Map(map_options)\n        m.add_source(EARTHQUAKE_SOURCE, earthquakes_source)\n        m.add_layer(earthquake_clusters)\n        m.add_layer(earthquake_circles)\n        m.add_popup(EARTHQUAKE_CLUSTERS, \"maxMag\")\n        m.add_layer(earthquake_labels)\n        return m\n\n    @reactive.Effect\n    @reactive.event(input.maplibre)\n    async def result():\n        print(f\"result: {input.maplibre()}\")\n\n\napp = App(app_ui, server)\n\nif __name__ == \"__main__\":\n    app.run()\n

    Run example:

    poetry run uvicorn docs.examples.earthquake_clusters.app:app --reload\n
    "},{"location":"examples/every_person_in_manhattan/","title":"Every person in manhattan","text":"
    import json\n\nimport pandas as pd\nimport shapely\nfrom pymaplibregl import (\n    Layer,\n    LayerType,\n    Map,\n    MapContext,\n    MapOptions,\n    output_maplibregl,\n    render_maplibregl,\n)\nfrom pymaplibregl.basemaps import Carto\nfrom pymaplibregl.sources import GeoJSONSource\nfrom pymaplibregl.utils import df_to_geojson\nfrom shiny import App, reactive, ui\n\nMALE_COLOR = \"rgb(0, 128, 255)\"\nFEMALE_COLOR = \"rgb(255, 0, 128)\"\nLAYER_ID = \"every-person-in-manhattan-circles\"\nCIRCLE_RADIUS = 2\n\npoint_data = pd.read_json(\n    \"https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/scatterplot/manhattan.json\"\n)\n\npoint_data.columns = [\"lng\", \"lat\", \"sex\"]\n\nevery_person_in_manhattan_source = GeoJSONSource(\n    data=df_to_geojson(point_data, properties=[\"sex\"]),\n)\n\nbbox = shapely.bounds(\n    shapely.from_geojson(json.dumps(every_person_in_manhattan_source.data))\n)\n\nevery_person_in_manhattan_circles = Layer(\n    type=LayerType.CIRCLE,\n    id=LAYER_ID,\n    source=every_person_in_manhattan_source,\n    paint={\n        \"circle-color\": [\"match\", [\"get\", \"sex\"], 1, MALE_COLOR, FEMALE_COLOR],\n        \"circle-radius\": CIRCLE_RADIUS,\n    },\n)\n\nmap_options = MapOptions(\n    style=Carto.POSITRON,\n    bounds=tuple(bbox),\n    fit_bounds_options={\"padding\": 20},\n)\n\napp_ui = ui.page_fluid(\n    ui.panel_title(\"Every Person in Manhattan\"),\n    output_maplibregl(\"maplibre\", height=600),\n    ui.input_slider(\"radius\", \"Radius\", value=CIRCLE_RADIUS, min=1, max=5),\n)\n\n\ndef server(input, output, session):\n    @render_maplibregl\n    async def maplibre():\n        m = Map(map_options)\n        m.add_layer(every_person_in_manhattan_circles)\n        return m\n\n    @reactive.Effect\n    @reactive.event(input.radius, ignore_init=True)\n    async def radius():\n        async with MapContext(\"maplibre\") as m:\n            m.set_paint_property(LAYER_ID, \"circle-radius\", input.radius())\n\n\napp = App(app_ui, server)\n\nif __name__ == \"__main__\":\n    app.run()\n

    Run example:

    poetry run uvicorn docs.examples.every_person_in_manhattan.app:app --reload\n
    "}]} \ No newline at end of file diff --git a/sitemap.xml.gz b/sitemap.xml.gz index 5dc8a750571226303379794c2098e96bc34688fc..3d378ed7588a92196264cb4765910ed67311aba9 100644 GIT binary patch delta 13 Ucmb=gXP58h;K +{% endblock %} + +{% block styles %} + {{ super() }} + +{% endblock %}