From 55fd99a020d8286f0199edb15f040b49c8d780bd Mon Sep 17 00:00:00 2001 From: Stefan Kuethe Date: Tue, 9 Jan 2024 10:20:25 +0100 Subject: [PATCH] Deployed 3ff6976 with MkDocs version: 1.5.3 --- 404.html | 99 +- api/basemaps/index.html | 99 +- api/controls/index.html | 99 +- api/layer/index.html | 192 +- api/map/index.html | 2285 ++++++++++++++--- api/sources/index.html | 99 +- .../__pycache__/app.cpython-39.pyc | Bin 0 -> 1587 bytes examples/3d_indoor_mapping/index.html | 99 +- .../basic_usage_shiny.cpython-39.pyc | Bin 1143 -> 0 bytes examples/airports/index.html | 99 +- examples/custom_basemap/index.html | 99 +- .../__pycache__/app.cpython-39.pyc | Bin 2430 -> 2432 bytes examples/earthquake_clusters/app.py | 4 +- examples/earthquake_clusters/index.html | 105 +- .../__pycache__/app.cpython-39.pyc | Bin 2284 -> 2403 bytes examples/every_person_in_manhattan/app.py | 4 +- examples/every_person_in_manhattan/index.html | 227 +- .../__pycache__/reactivity.cpython-39.pyc | Bin 0 -> 2071 bytes .../__pycache__/shiny_ui.cpython-39.pyc | Bin 0 -> 1624 bytes examples/{ => getting_started}/basic_usage.py | 7 +- .../basic_usage_shiny.py | 0 examples/getting_started/reactivity.py | 69 + examples/jupyter/getting_started.ipynb | 307 +++ .../__pycache__/app.cpython-39.pyc | Bin 0 -> 2700 bytes examples/vancouver_blocks/app.py | 100 + examples/vancouver_blocks/index.html | 948 +++++++ index.html | 148 +- jupyter/index.html | 907 +++++++ layers/index.html | 881 +++++++ objects.inv | Bin 532 -> 620 bytes search/search_index.json | 2 +- shiny/index.html | 1122 ++++++++ sitemap.xml.gz | Bin 127 -> 127 bytes 33 files changed, 7297 insertions(+), 704 deletions(-) create mode 100644 examples/3d_indoor_mapping/__pycache__/app.cpython-39.pyc delete mode 100644 examples/__pycache__/basic_usage_shiny.cpython-39.pyc create mode 100644 examples/getting_started/__pycache__/reactivity.cpython-39.pyc create mode 100644 examples/getting_started/__pycache__/shiny_ui.cpython-39.pyc rename examples/{ => getting_started}/basic_usage.py (84%) rename examples/{ => getting_started}/basic_usage_shiny.py (100%) create mode 100644 examples/getting_started/reactivity.py create mode 100644 examples/jupyter/getting_started.ipynb create mode 100644 examples/vancouver_blocks/__pycache__/app.cpython-39.pyc create mode 100644 examples/vancouver_blocks/app.py create mode 100644 examples/vancouver_blocks/index.html create mode 100644 jupyter/index.html create mode 100644 layers/index.html create mode 100644 shiny/index.html diff --git a/404.html b/404.html index a6f532c6..f7a13fe9 100644 --- a/404.html +++ b/404.html @@ -16,7 +16,7 @@ - Pymaplibregl + py-maplibregl @@ -81,9 +81,11 @@ -
+ + +
+
+ + + + + +
+
+ + + + + + + +

Map

+ +
+ + + + +

+ pymaplibregl.Map + + +

+ + +
+

+ Bases: object

+ + +

Map

+ +

Parameters:

@@ -1190,7 +1501,32 @@

199 200 201 -202

class Map(object):
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
class Map(object):
     """Map
 
     Args:
@@ -1209,129 +1545,154 @@ 

MESSAGE = "not implemented yet" def __init__(self, map_options: MapOptions = MapOptions(), **kwargs): - self._map_options = map_options.to_dict() | kwargs - self._calls = [] + self.map_options = map_options.to_dict() | kwargs + self._message_queue = [] 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} + return {"mapOptions": self.map_options, "calls": self._message_queue} - @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 - - Args: - control (Control): The control to be add to the map. - position (str | ControlPosition): The position of the control. - """ - 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}) + """ + @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._message_queue.append( + {"name": "applyFunc", "data": {"funcName": func_name, "params": params}} + ) + + def add_call(self, method_name: str, *args) -> None: + """Add a method call that is executed on the map instance + + Args: + method_name (str): The name of the map method to be executed. + *args (any): The arguments to be passed to the map method. + """ + # TODO: Pass as dict? {"name": method_name, "args": args} + call = [method_name, args] + self._message_queue.append(call) + + def add_control( + self, + control: Control, + position: [str | ControlPosition] = ControlPosition.TOP_RIGHT, + ) -> None: + """Add a control to the map + + Args: + control (Control): The control to be added to the map. + position (str | ControlPosition): The position of the control. + """ + self.add_call( + "addControl", + control.type, + control.to_dict(), + ControlPosition(position).value, + ) + + def add_source(self, id: str, source: [Source | dict]) -> None: + """Add a source to the map""" + if isinstance(source, Source): + source = source.to_dict() - def add_marker(self, marker: Marker) -> None: - """Add a marker to the map - - Args: - marker (Marker): The marker to be added 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]) + self.add_call("addSource", id, 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.add_call("addLayer", layer) + + def add_marker(self, marker: Marker) -> None: + """Add a marker to the map + + Args: + marker (Marker): The marker to be added to the map. + """ + self.add_call("addMarker", marker.to_dict()) + + def add_popup(self, layer_id: str, prop: str) -> None: + """Add a popup to the map + + Args: + layer_id (str): The layer to which the popup is added. + prop (str): The property of the source to be displayed. + """ + self.add_call("addPopup", layer_id, prop) + + def add_tooltip(self, layer_id: str, prop: str) -> None: + """Add a tooltip to the map - 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, **kwargs) -> str: - """Render to html - - Args: - **kwargs (Any): Additional keyword arguments that are passed to the template. - Currently, `style` is the only supported keyword argument. - - Examples: - >>> from pymaplibregl import Map - - >>> map = Map() - >>> with open("/tmp/map.html", "w") as f: - ... f.write(map.to_html(style="height: 800px;") - """ - 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 - ) - return output + Args: + layer_id (str): The layer to which the tooltip is added. + prop (str): The property of the source to be displayed. + """ + self.add_call("addTooltip", layer_id, 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, **kwargs) -> str: + """Render to html + + Args: + **kwargs (Any): Additional keyword arguments that are passed to the template. + Currently, `style` is the only supported keyword argument. + + Examples: + >>> from pymaplibregl import Map + + >>> map = Map() + >>> with open("/tmp/map.html", "w") as f: + ... f.write(map.to_html(style="height: 800px;") # doctest: +SKIP + """ + 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 + ) + return output

@@ -1353,15 +1714,15 @@

-

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

+ add_call(method_name, *args)

-

Add a control to the map

+

Add a method call that is executed on the map instance

@@ -1377,13 +1738,13 @@

- control + method_name - Control + str
-

The control to be add to the map.

+

The name of the map method to be executed.

@@ -1391,17 +1752,17 @@

- position + *args - str | ControlPosition + any
-

The position of the control.

+

The arguments to be passed to the map method.

- TOP_RIGHT + () @@ -1409,9 +1770,7 @@

Source code in pymaplibregl/map.py -
- + + + + + + +
104
-105
-106
+            
106
 107
 108
 109
@@ -1420,28 +1779,16 @@ 

112 113 114 -115 -116 -117 -118 -119 -120

def add_control(
-    self,
-    control: Control,
-    position: [str | ControlPosition] = ControlPosition.TOP_RIGHT,
-) -> None:
-    """Add a control to the map
-
-    Args:
-        control (Control): The control to be add to the map.
-        position (str | ControlPosition): The position of the control.
-    """
-    data = {
-        "type": control.type,
-        "options": control.to_dict(),
-        "position": ControlPosition(position).value,
-    }
-    self._calls.append({"name": "addControl", "data": data})
+115
def add_call(self, method_name: str, *args) -> None:
+    """Add a method call that is executed on the map instance
+
+    Args:
+        method_name (str): The name of the map method to be executed.
+        *args (any): The arguments to be passed to the map method.
+    """
+    # TODO: Pass as dict? {"name": method_name, "args": args}
+    call = [method_name, args]
+    self._message_queue.append(call)
 
@@ -1454,15 +1801,15 @@

-

- add_layer(layer) +

+ add_control(control, position=ControlPosition.TOP_RIGHT)

-

Add a layer to the map

+

Add a control to the map

@@ -1478,43 +1825,71 @@

layercontrol - Layer | dict + Control
-

The Layer to be added to the map.

+

The control to be added to the map.

required
position + str | ControlPosition + +
+

The position of the control.

+
+
+ TOP_RIGHT +
Source code in pymaplibregl/map.py -
- +
129
+            
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})
+133
def add_control(
+    self,
+    control: Control,
+    position: [str | ControlPosition] = ControlPosition.TOP_RIGHT,
+) -> None:
+    """Add a control to the map
+
+    Args:
+        control (Control): The control to be added to the map.
+        position (str | ControlPosition): The position of the control.
+    """
+    self.add_call(
+        "addControl",
+        control.type,
+        control.to_dict(),
+        ControlPosition(position).value,
+    )
 
@@ -1527,15 +1902,15 @@

-

- add_marker(marker) +

+ add_layer(layer)

-

Add a marker to the map

+

Add a layer to the map

@@ -1551,13 +1926,13 @@

markerlayer - Marker + Layer | dict
-

The marker to be added to the map.

+

The Layer to be added to the map.

@@ -1569,19 +1944,25 @@

Source code in pymaplibregl/map.py -
140
-141
-142
+            
def add_marker(self, marker: Marker) -> None:
-    """Add a marker to the map
-
-    Args:
-        marker (Marker): The marker to be added to the map.
-    """
-    self._calls.append({"name": "addMarker", "data": marker.to_dict()})
+146
+147
+148
+149
+150
+151
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.add_call("addLayer", layer)
 
@@ -1594,62 +1975,61 @@

-

- add_popup(layer_id, prop) +

+ add_marker(marker)

-

Add a popup to the map

- -
- Source code in pymaplibregl/map.py -
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 marker to the map

-

-
- -

Add a source to the map

+

Parameters:

+ + + + + + + + + + + + + + + + + +
NameTypeDescriptionDefault
marker + Marker + +
+

The marker to be added to the map.

+
+
+ required +
Source code in pymaplibregl/map.py -
- + + + + + + +
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_marker(self, marker: Marker) -> None:
+    """Add a marker to the map
+
+    Args:
+        marker (Marker): The marker to be added to the map.
+    """
+    self.add_call("addMarker", marker.to_dict())
 
@@ -1662,15 +2042,15 @@

-

- set_filter(layer_id, filter_) +

+ add_popup(layer_id, prop)

-

Update the filter of a layer

+

Add a popup to the map

@@ -1692,7 +2072,7 @@

-

The name of the layer to be updated.

+

The layer to which the popup is added.

@@ -1700,7 +2080,208 @@

filter_prop + str + +
+

The property of the source to be displayed.

+
+
+ required +
+ +
+ Source code in pymaplibregl/map.py +
def add_popup(self, layer_id: str, prop: str) -> None:
+    """Add a popup to the map
+
+    Args:
+        layer_id (str): The layer to which the popup is added.
+        prop (str): The property of the source to be displayed.
+    """
+    self.add_call("addPopup", layer_id, prop)
+
+
+
+ +
+ + +
+ + + + +

+ add_source(id, source) + +

+ + +
+ +

Add a source to the map

+ +
+ Source code in pymaplibregl/map.py +
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.add_call("addSource", id, source)
+
+
+
+ +
+ + +
+ + + + +

+ add_tooltip(layer_id, prop) + +

+ + +
+ +

Add a tooltip to the map

+ + + +

Parameters:

+ + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionDefault
layer_id + str + +
+

The layer to which the tooltip is added.

+
+
+ required +
prop + str + +
+

The property of the source to be displayed.

+
+
+ required +
+ +
+ Source code in pymaplibregl/map.py +
def add_tooltip(self, layer_id: str, prop: str) -> None:
+    """Add a tooltip to the map
+
+    Args:
+        layer_id (str): The layer to which the tooltip is added.
+        prop (str): The property of the source to be displayed.
+    """
+    self.add_call("addTooltip", layer_id, prop)
+
+
+
+ +
+ + +
+ + + + +

+ set_filter(layer_id, filter_) + +

+ + +
+ +

Update the filter of a layer

+ + + +

Parameters:

+ + + + + + + + + + + + + + + + + + @@ -1718,21 +2299,21 @@

Source code in pymaplibregl/map.py -

NameTypeDescriptionDefault
layer_id + str + +
+

The name of the layer to be updated.

+
+
+ required +
filter_ list
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_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_)
 
@@ -1815,23 +2396,23 @@

Source code in pymaplibregl/map.py -
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 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)
 
@@ -1914,23 +2495,23 @@

Source code in pymaplibregl/map.py -
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_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)
 
@@ -1996,45 +2577,45 @@

Source code in pymaplibregl/map.py -
def to_html(self, **kwargs) -> str:
-    """Render to html
-
-    Args:
-        **kwargs (Any): Additional keyword arguments that are passed to the template.
-            Currently, `style` is the only supported keyword argument.
-
-    Examples:
-        >>> from pymaplibregl import Map
-
-        >>> map = Map()
-        >>> with open("/tmp/map.html", "w") as f:
-        ...     f.write(map.to_html(style="height: 800px;")
-    """
-    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
-    )
-    return output
+            
def to_html(self, **kwargs) -> str:
+    """Render to html
+
+    Args:
+        **kwargs (Any): Additional keyword arguments that are passed to the template.
+            Currently, `style` is the only supported keyword argument.
+
+    Examples:
+        >>> from pymaplibregl import Map
+
+        >>> map = Map()
+        >>> with open("/tmp/map.html", "w") as f:
+        ...     f.write(map.to_html(style="height: 800px;") # doctest: +SKIP
+    """
+    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
+    )
+    return output
 
@@ -2172,6 +2753,952 @@

+ + + + + + +
+ + + + +

+ pymaplibregl.ipywidget.MapWidget + + +

+ + +
+

+ Bases: AnyWidget, Map

+ + +
+ Source code in pymaplibregl/ipywidget.py +
class MapWidget(AnyWidget, Map):
+    _esm = join(Path(__file__).parent, "srcjs", "ipywidget.js")
+    _css = join(Path(__file__).parent, "srcjs", "maplibre-gl.css")
+    _rendered = traitlets.Bool(False, config=True).tag(sync=True)
+    map_options = traitlets.Dict().tag(sync=True)
+    height = traitlets.Union([traitlets.Int(), traitlets.Unicode()]).tag(sync=True)
+    lng_lat = traitlets.Dict().tag(sync=True)
+
+    def __init__(self, map_options=MapOptions(), **kwargs) -> None:
+        # self.map_options = map_options.to_dict()
+        # self._message_queue = []
+        # super().__init__(**kwargs)
+        AnyWidget.__init__(self, **kwargs)
+        Map.__init__(self, map_options, **kwargs)
+
+    @traitlets.default("height")
+    def _default_height(self):
+        return "400px"
+
+    @traitlets.validate("height")
+    def _validate_height(self, proposal):
+        height = proposal["value"]
+        if isinstance(height, int):
+            return f"{height}px"
+
+        return height
+
+    @traitlets.observe("_rendered")
+    def _on_rendered(self, change):
+        self.send({"calls": self._message_queue, "msg": "init"})
+        self._message_queue = []
+
+    def add_call(self, method_name: str, *args) -> None:
+        call = [method_name, args]
+        if not self._rendered:
+            self._message_queue.append(call)
+            return
+
+        self.send({"calls": [call], "msg": "custom call"})
+
+
+ + + +
+ + + + + + + + + + +
+ + + + +

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

+ + +
+ +

Add a control to the map

+ + + +

Parameters:

+ + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionDefault
control + Control + +
+

The control to be added to the map.

+
+
+ required +
position + str | ControlPosition + +
+

The position of the control.

+
+
+ TOP_RIGHT +
+ +
+ Source code in pymaplibregl/map.py +
def add_control(
+    self,
+    control: Control,
+    position: [str | ControlPosition] = ControlPosition.TOP_RIGHT,
+) -> None:
+    """Add a control to the map
+
+    Args:
+        control (Control): The control to be added to the map.
+        position (str | ControlPosition): The position of the control.
+    """
+    self.add_call(
+        "addControl",
+        control.type,
+        control.to_dict(),
+        ControlPosition(position).value,
+    )
+
+
+
+ +
+ + +
+ + + + +

+ add_layer(layer) + +

+ + +
+ +

Add a layer to the map

+ + + +

Parameters:

+ + + + + + + + + + + + + + + + + +
NameTypeDescriptionDefault
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:
+    """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.add_call("addLayer", layer)
+
+
+
+ +
+ + +
+ + + + +

+ add_marker(marker) + +

+ + +
+ +

Add a marker to the map

+ + + +

Parameters:

+ + + + + + + + + + + + + + + + + +
NameTypeDescriptionDefault
marker + Marker + +
+

The marker to be added to the map.

+
+
+ required +
+ +
+ Source code in pymaplibregl/map.py +
def add_marker(self, marker: Marker) -> None:
+    """Add a marker to the map
+
+    Args:
+        marker (Marker): The marker to be added to the map.
+    """
+    self.add_call("addMarker", marker.to_dict())
+
+
+
+ +
+ + +
+ + + + +

+ add_popup(layer_id, prop) + +

+ + +
+ +

Add a popup to the map

+ + + +

Parameters:

+ + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionDefault
layer_id + str + +
+

The layer to which the popup is added.

+
+
+ required +
prop + str + +
+

The property of the source to be displayed.

+
+
+ required +
+ +
+ Source code in pymaplibregl/map.py +
def add_popup(self, layer_id: str, prop: str) -> None:
+    """Add a popup to the map
+
+    Args:
+        layer_id (str): The layer to which the popup is added.
+        prop (str): The property of the source to be displayed.
+    """
+    self.add_call("addPopup", layer_id, prop)
+
+
+
+ +
+ + +
+ + + + +

+ add_source(id, source) + +

+ + +
+ +

Add a source to the map

+ +
+ Source code in pymaplibregl/map.py +
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.add_call("addSource", id, source)
+
+
+
+ +
+ + +
+ + + + +

+ add_tooltip(layer_id, prop) + +

+ + +
+ +

Add a tooltip to the map

+ + + +

Parameters:

+ + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionDefault
layer_id + str + +
+

The layer to which the tooltip is added.

+
+
+ required +
prop + str + +
+

The property of the source to be displayed.

+
+
+ required +
+ +
+ Source code in pymaplibregl/map.py +
def add_tooltip(self, layer_id: str, prop: str) -> None:
+    """Add a tooltip to the map
+
+    Args:
+        layer_id (str): The layer to which the tooltip is added.
+        prop (str): The property of the source to be displayed.
+    """
+    self.add_call("addTooltip", layer_id, prop)
+
+
+
+ +
+ + +
+ + + + +

+ set_filter(layer_id, filter_) + +

+ + +
+ +

Update the filter of a layer

+ + + +

Parameters:

+ + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionDefault
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):
+    """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:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionDefault
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:
+    """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:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionDefault
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:
+    """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)
+
+
+
+ +
+ + +
+ + + + +

+ to_html(**kwargs) + +

+ + +
+ +

Render to html

+ + + +

Parameters:

+ + + + + + + + + + + + + + + + + +
NameTypeDescriptionDefault
**kwargs + Any + +
+

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

+
+
+ {} +
+ + + +

Examples:

+
>>> from pymaplibregl import Map
+
+
>>> map = Map()
+>>> with open("/tmp/map.html", "w") as f:
+...     f.write(map.to_html(style="height: 800px;")
+
+ +
+ Source code in pymaplibregl/map.py +
def to_html(self, **kwargs) -> str:
+    """Render to html
+
+    Args:
+        **kwargs (Any): Additional keyword arguments that are passed to the template.
+            Currently, `style` is the only supported keyword argument.
+
+    Examples:
+        >>> from pymaplibregl import Map
+
+        >>> map = Map()
+        >>> with open("/tmp/map.html", "w") as f:
+        ...     f.write(map.to_html(style="height: 800px;") # doctest: +SKIP
+    """
+    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
+    )
+    return output
+
+
+
+ +
+ + +
@@ -2223,7 +3750,7 @@

- + diff --git a/api/sources/index.html b/api/sources/index.html index 2da7a7d1..a0783fc2 100644 --- a/api/sources/index.html +++ b/api/sources/index.html @@ -20,7 +20,7 @@ - Sources - Pymaplibregl + Sources - py-maplibregl @@ -90,9 +90,11 @@ -
+ + +