-
Notifications
You must be signed in to change notification settings - Fork 39
feat: Create richer Basemap
class and deprecate basemap_style
arg
#935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
ed77539
feat: Create `Basemap` class to replace deprecated `basemap_style` arg
kylebarron 32925c1
Rename `basemap_style` to `style`
kylebarron 177f955
fix kwarg
kylebarron 4f79c71
from future import annotations
kylebarron 5f3b6de
Merge branch 'main' into kyle/basemap-refactor
kylebarron 4dc98f5
Implement TS side and support interleaved rendering
kylebarron 6c2901e
Rename CartoBasemap to CartoStyle
kylebarron d15885f
Interleaved should be passed to DeckGLOverlay, not Maplibre Map
kylebarron d38dae5
allow None on basemap trait (even though we don't support rendering w…
kylebarron 01f82bf
handle setting basemap state to null, even though we still always ren…
kylebarron 12796e2
specify vector basemap
kylebarron fc30a08
Support not rendering basemap
kylebarron 4c69eee
Remove tailwind utilities
kylebarron c33a502
fix: Reinstate Tailwind utilities
vgeorge b3ec268
fix: Change red background to transparent to eliminate flash
vgeorge 5af42f1
chore: Update package-lock.json
vgeorge 54bdcb0
lint
kylebarron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# lonboard.basemap | ||
|
||
::: lonboard.basemap.CartoBasemap | ||
::: lonboard.basemap.CartoStyle | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,78 @@ | ||
"""Basemap helpers.""" | ||
|
||
from __future__ import annotations | ||
|
||
from enum import Enum | ||
from typing import TYPE_CHECKING | ||
|
||
import traitlets as t | ||
from typing_extensions import deprecated | ||
|
||
from lonboard._base import BaseWidget | ||
from lonboard.traits import BasemapUrl | ||
|
||
if TYPE_CHECKING: | ||
from typing import Literal | ||
|
||
|
||
class CartoStyle(str, Enum): | ||
"""Maplibre-supported vector basemap styles provided by Carto. | ||
|
||
Refer to [Carto | ||
documentation](https://docs.carto.com/carto-for-developers/carto-for-react/guides/basemaps) | ||
for information on styles. | ||
""" | ||
|
||
DarkMatter = "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json" | ||
"""A dark map style with labels. | ||
|
||
 | ||
""" | ||
|
||
DarkMatterNoLabels = ( | ||
"https://basemaps.cartocdn.com/gl/dark-matter-nolabels-gl-style/style.json" | ||
) | ||
"""A dark map style without labels. | ||
|
||
 | ||
""" | ||
|
||
Positron = "https://basemaps.cartocdn.com/gl/positron-gl-style/style.json" | ||
"""A light map style with labels. | ||
|
||
 | ||
""" | ||
|
||
PositronNoLabels = ( | ||
"https://basemaps.cartocdn.com/gl/positron-nolabels-gl-style/style.json" | ||
) | ||
"""A light map style without labels. | ||
|
||
 | ||
""" | ||
|
||
Voyager = "https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json" | ||
"""A light, colored map style with labels. | ||
|
||
 | ||
""" | ||
|
||
VoyagerNoLabels = ( | ||
"https://basemaps.cartocdn.com/gl/voyager-nolabels-gl-style/style.json" | ||
) | ||
"""A light, colored map style without labels. | ||
|
||
 | ||
""" | ||
|
||
|
||
# NOTE: this is fully duplicated because you can't subclass enums, and I don't see any | ||
# other way to provide a deprecation warning | ||
@deprecated( | ||
"CartoBasemap is deprecated, use CartoStyle instead. Will be removed in v0.14", | ||
) | ||
class CartoBasemap(str, Enum): | ||
"""Basemap styles provided by Carto. | ||
"""Maplibre-supported vector basemap styles provided by Carto. | ||
|
||
Refer to [Carto | ||
documentation](https://docs.carto.com/carto-for-developers/carto-for-react/guides/basemaps) | ||
|
@@ -20,7 +88,10 @@ class CartoBasemap(str, Enum): | |
DarkMatterNoLabels = ( | ||
"https://basemaps.cartocdn.com/gl/dark-matter-nolabels-gl-style/style.json" | ||
) | ||
"""A dark map style without labels.""" | ||
"""A dark map style without labels. | ||
|
||
 | ||
""" | ||
|
||
Positron = "https://basemaps.cartocdn.com/gl/positron-gl-style/style.json" | ||
"""A light map style with labels. | ||
|
@@ -31,7 +102,10 @@ class CartoBasemap(str, Enum): | |
PositronNoLabels = ( | ||
"https://basemaps.cartocdn.com/gl/positron-nolabels-gl-style/style.json" | ||
) | ||
"""A light map style without labels.""" | ||
"""A light map style without labels. | ||
|
||
 | ||
""" | ||
|
||
Voyager = "https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json" | ||
"""A light, colored map style with labels. | ||
|
@@ -42,4 +116,62 @@ class CartoBasemap(str, Enum): | |
VoyagerNoLabels = ( | ||
"https://basemaps.cartocdn.com/gl/voyager-nolabels-gl-style/style.json" | ||
) | ||
"""A light, colored map style without labels.""" | ||
"""A light, colored map style without labels. | ||
|
||
 | ||
""" | ||
|
||
|
||
class MaplibreBasemap(BaseWidget): | ||
"""A MapLibre GL JS basemap.""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve this docstring |
||
|
||
def __init__( | ||
self, | ||
*, | ||
mode: Literal[ | ||
"interleaved", | ||
"overlaid", | ||
"reverse-controlled", | ||
] = "reverse-controlled", | ||
style: str | CartoStyle = CartoStyle.PositronNoLabels, | ||
) -> None: | ||
"""Create a MapLibre GL JS basemap.""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. todo: improve this docstring |
||
super().__init__(mode=mode, style=style) | ||
|
||
mode = t.Enum( | ||
[ | ||
"interleaved", | ||
"overlaid", | ||
"reverse-controlled", | ||
], | ||
default_value="reverse-controlled", | ||
).tag(sync=True) | ||
"""The basemap integration mode. | ||
|
||
- **`"interleaved"`**: | ||
|
||
The interleaved mode renders deck.gl layers into the same context created by MapLibre. If you need to mix deck.gl layers with MapLibre layers, e.g. having deck.gl surfaces below text labels, or objects occluding each other correctly in 3D, then you have to use this option. | ||
|
||
- **`"overlaid"`**: | ||
|
||
The overlaid mode renders deck.gl in a separate canvas inside the MapLibre's controls container. If your use case does not require interleaving, but you still want to use certain features of maplibre-gl, such as globe view, then you should use this option. | ||
|
||
- **`"reverse-controlled"`**: | ||
|
||
The reverse-controlled mode renders deck.gl above the MapLibre container and blocks any interaction to the base map. | ||
|
||
If you need to have multiple views, you should use this option. | ||
|
||
**Default**: `"reverse-controlled"` | ||
""" | ||
|
||
style = BasemapUrl(CartoStyle.PositronNoLabels).tag(sync=True) | ||
kylebarron marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
A URL to a MapLibre-compatible basemap style. | ||
|
||
Various styles are provided in [`lonboard.basemap`](https://developmentseed.org/lonboard/latest/api/basemap/). | ||
|
||
- Type: `str`, holding a URL hosting a basemap style. | ||
- Default | ||
[`lonboard.basemap.CartoStyle.PositronNoLabels`][lonboard.basemap.CartoStyle.PositronNoLabels] | ||
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add
MaplibreBasemap
to the docs here