From fdb7e6693ef5baa2ff975399faf0d147e893c893 Mon Sep 17 00:00:00 2001 From: Vitor George Date: Mon, 1 Jul 2024 12:19:34 +0100 Subject: [PATCH 1/5] Add Maplibre CSS import --- src/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.tsx b/src/index.tsx index 3bb13703..2bc148a1 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -14,6 +14,7 @@ import { v4 as uuidv4 } from "uuid"; import { Message } from "./types.js"; import { flyTo } from "./actions/fly-to.js"; import { useViewStateDebounced } from "./state"; +import "maplibre-gl/dist/maplibre-gl.css"; await initParquetWasm(); From 40f76d3d3ada24e3496a634595a47f0c534a2c5e Mon Sep 17 00:00:00 2001 From: Vitor George Date: Mon, 1 Jul 2024 12:21:46 +0100 Subject: [PATCH 2/5] Enable custom attribution --- lonboard/_map.py | 32 ++++++++++++++++++++++++++++++++ src/index.tsx | 6 +++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/lonboard/_map.py b/lonboard/_map.py index bf207e0a..e98d5c97 100644 --- a/lonboard/_map.py +++ b/lonboard/_map.py @@ -167,6 +167,38 @@ def __init__( [`lonboard.basemap.CartoBasemap.PositronNoLabels`][lonboard.basemap.CartoBasemap.PositronNoLabels] """ + custom_attribution = traitlets.Union( + [traitlets.Unicode(allow_none=True), traitlets.List(traitlets.Unicode(allow_none=False))] + ).tag(sync=True) + """ + Custom attribution to display on the map. + + This attribute supports the same format as the `attribution` property in the Maplibre API. + + - Type: `str` or `List[str]` + - Default: `None` + + You can provide either a single string or a list of strings for custom attributions. If an attribution value is set in the map style, it will be displayed in addition to this custom attribution. + + **Example:** + + ```py + m = Map( + layers, + custom_attribution="Development Seed" + ) + ``` + + **Example:** + + ```py + m = Map( + layers, + custom_attribution=["Development Seed", "OpenStreetMap"] + ) + ``` + """ + # TODO: We'd prefer a "Strict union of bool and float" but that doesn't # work here because `Union[bool, float]` would coerce `1` to `True`, which we don't # want, and `Union[float, bool]` would coerce `True` to `1`, which we also don't diff --git a/src/index.tsx b/src/index.tsx index 2bc148a1..a821a1c5 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -72,6 +72,7 @@ function App() { let [pickingRadius] = useModelState("picking_radius"); let [useDevicePixels] = useModelState("use_device_pixels"); let [parameters] = useModelState("parameters"); + let [customAttribution] = useModelState("custom_attribution"); // initialViewState is the value of view_state on the Python side. This is // called `initial` here because it gets passed in to deck's @@ -185,7 +186,10 @@ function App() { }} parameters={parameters || {}} > - + ); From 4628b62983b68484f6ee9eadce238d1c2f93167b Mon Sep 17 00:00:00 2001 From: Vitor George Date: Mon, 1 Jul 2024 12:22:12 +0100 Subject: [PATCH 3/5] Remove console.log --- src/model/base-layer.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/model/base-layer.ts b/src/model/base-layer.ts index b707c31e..42ef8de9 100644 --- a/src/model/base-layer.ts +++ b/src/model/base-layer.ts @@ -62,8 +62,6 @@ export abstract class BaseLayerModel extends BaseModel { } baseLayerProps(): LayerProps { - // console.log("extensions", this.extensionInstances()); - // console.log("extensionprops", this.extensionProps()); return { extensions: this.extensionInstances(), ...this.extensionProps(), From cc916eed7bbaef838d04805e7740002676653718 Mon Sep 17 00:00:00 2001 From: Vitor George Date: Mon, 1 Jul 2024 12:48:18 +0100 Subject: [PATCH 4/5] Fix lint errors --- lonboard/_map.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lonboard/_map.py b/lonboard/_map.py index e98d5c97..128bf93e 100644 --- a/lonboard/_map.py +++ b/lonboard/_map.py @@ -168,7 +168,10 @@ def __init__( """ custom_attribution = traitlets.Union( - [traitlets.Unicode(allow_none=True), traitlets.List(traitlets.Unicode(allow_none=False))] + [ + traitlets.Unicode(allow_none=True), + traitlets.List(traitlets.Unicode(allow_none=False)), + ] ).tag(sync=True) """ Custom attribution to display on the map. @@ -181,7 +184,7 @@ def __init__( You can provide either a single string or a list of strings for custom attributions. If an attribution value is set in the map style, it will be displayed in addition to this custom attribution. **Example:** - + ```py m = Map( layers, From 4595de55e5456c9df643525fe90e31015d25df8f Mon Sep 17 00:00:00 2001 From: Vitor George Date: Mon, 1 Jul 2024 13:01:06 +0100 Subject: [PATCH 5/5] More lint fixes --- lonboard/_map.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lonboard/_map.py b/lonboard/_map.py index 128bf93e..a18318cd 100644 --- a/lonboard/_map.py +++ b/lonboard/_map.py @@ -176,12 +176,15 @@ def __init__( """ Custom attribution to display on the map. - This attribute supports the same format as the `attribution` property in the Maplibre API. + This attribute supports the same format as the `attribution` property in the + Maplibre API. - Type: `str` or `List[str]` - Default: `None` - You can provide either a single string or a list of strings for custom attributions. If an attribution value is set in the map style, it will be displayed in addition to this custom attribution. + You can provide either a single string or a list of strings for custom attributions. + If an attribution value is set in the map style, it will be displayed in addition to + this custom attribution. **Example:**