Skip to content

Conversation

kylebarron
Copy link
Member

@kylebarron kylebarron commented Oct 15, 2025

Change list

Rendering layer interleaved in maplibre layer stack:

image

TODO:

  • Validation for beforeId. If beforeId is passed to a layer, try to resolve the basemap style URL to a dict, and then validate that the string value of beforeId exists in that layer stack. Keep a cache of fetched styles so that you're not fetching them repeatedly.
  • Warn if beforeId is set when the basemap style is not "interleaved"?
  • (next PR): integration with https://github.com/geopandas/xyzservices (see Basemap refactor #494)
  • (possibly future PR): examples of rendering different basemap modes

For #494

@github-actions github-actions bot added the feat label Oct 15, 2025


class MaplibreBasemap(BaseWidget):
"""A MapLibre GL JS basemap."""
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improve this docstring

] = "reverse-controlled",
style: str | CartoStyle = CartoStyle.PositronNoLabels,
) -> None:
"""Create a MapLibre GL JS basemap."""
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: improve this docstring

# lonboard.basemap

::: lonboard.basemap.CartoBasemap
::: lonboard.basemap.CartoStyle
Copy link
Member Author

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

const [stateCounter, setStateCounter] = useState<Date>(new Date());
const updateStateCallback = () => setStateCounter(new Date());

useEffect(() => {
Copy link
Member Author

@kylebarron kylebarron Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: in the future, we should figure out a way to refactor some of this code out of the top-level App, because it's pretty ugly having all of this layer model, basemap model, view model, etc, state in the top-level body.

@kylebarron kylebarron requested review from Copilot and vgeorge October 15, 2025 03:36
@kylebarron kylebarron mentioned this pull request Oct 15, 2025
2 tasks
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a richer Basemap class system to replace the simple string-based basemap_style parameter, enabling better control over map rendering modes and basemap configuration.

  • Adds new MaplibreBasemap class with configurable rendering modes ("interleaved", "overlaid", "reverse-controlled")
  • Deprecates basemap_style parameter in favor of the new basemap parameter
  • Adds before_id parameter to layers for controlling render order in interleaved mode

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/renderers/types.ts Adds OverlayRendererProps type for interleaved rendering support
src/renderers/overlay.tsx Updates overlay renderer to accept interleaved prop
src/model/initialize.ts Extracts loadModel helper function for loading widget models
src/model/basemap.ts Creates new MaplibreBasemapModel class with mode and style properties
src/model/base-layer.ts Adds beforeId property to base layer for render order control
src/index.tsx Updates main component to use new basemap system and removes deprecated render_mode
lonboard/types/map.py Updates type definitions to use new MaplibreBasemap instead of CartoBasemap
lonboard/traits.py Removes unnecessary sync tag from trait initialization
lonboard/basemap.py Adds MaplibreBasemap class and renames CartoBasemap to CartoStyle
lonboard/_viz.py Updates viz function to use new basemap system
lonboard/_map.py Implements deprecation warnings and migration for basemap_style
lonboard/_layer.py Adds before_id trait to base layer class
docs/api/basemap.md Updates documentation to reference CartoStyle instead of CartoBasemap

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@vgeorge
Copy link
Member

vgeorge commented Oct 16, 2025

@kylebarron considering it's possible to pass None to the base map prop, shouldn't the Map component render a blank canvas? Right now it's still displaying the default basemap. Just wondering if that's something we’re addressing in this PR or planning to handle separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants