Skip to content

feat: support MapLibre V5 in hubble.gl tool #3436

Draft
lixun910 wants to merge 2 commits into
masterfrom
xli-fix-hubble-w-maplibre5
Draft

feat: support MapLibre V5 in hubble.gl tool #3436
lixun910 wants to merge 2 commits into
masterfrom
xli-fix-hubble-w-maplibre5

Conversation

@lixun910
Copy link
Copy Markdown
Collaborator

Hubble's ExportVideoPanelPreview internally calls applyViewStateToTransform, which directly assigns to the map's transform properties (tr.bearing = ..., tr.pitch = ..., etc.).

In MapLibre v4, transform.bearing and similar properties had writable setters, so this worked fine.

In MapLibre v5, these properties were changed to getter-only (read-only accessors). When the Mapbox adapter tries to write to them, it throws error.

The fix provide a compatibility shim: getHubbleMapLib() dynamically imports maplibre-gl and returns a patched version:

  • Subclasses maplibre.Map as HubbleMapLibreMap
  • After construction, patches the transform instance via patchMapLibreTransformForHubble()
  • Redefines getter-only properties (bearing, pitch, zoom, padding, _center, _zoom) to add setters that delegate to the v5 setter methods (setBearing(), setPitch(), etc.)
  • Stubs out internal methods (_constrain, _calcMatrices) that Hubble's adapter may call but don't exist on v5 transforms

lixun910 added 2 commits May 12, 2026 17:10
…mpatibility

- Introduced `getHubbleMapLib` function to lazily load the MapLibre library.
- Created `HubbleMapLibreMap` class extending MapLibre's Map with custom transformations.
- Added compatibility patches for MapLibre's transform methods to support Hubble-specific functionality.
- Enhanced property descriptors for better integration with Hubble's requirements.
Copilot AI review requested due to automatic review settings May 13, 2026 00:21
Copy link
Copy Markdown
Contributor

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 updates the Hubble video export integration to work with MapLibre v5 by providing a compatibility shim that restores setter-style access for transform properties expected by Hubble’s Mapbox adapter.

Changes:

  • Replace direct import('maplibre-gl') usage in getStaticMapProps with a cached getHubbleMapLib() that returns a patched MapLibre module.
  • Add a HubbleMapLibreMap subclass that patches the map’s transform instance after construction.
  • Introduce transform patching helpers that re-add setters for read-only transform accessors and stub missing internal methods.
Comments suppressed due to low confidence (1)

src/components/src/modals/hubble-utils.ts:201

  • Same issue as _constrain: _calcMatrices is defined as a no-op unconditionally, which can override an existing implementation (breaking rendering/interaction) or throw if the property is non-configurable. It should only be stubbed when it does not already exist (and the descriptor is configurable).
  Object.defineProperty(transform, '_calcMatrices', {
    value() {},
    writable: true,
    configurable: true
  });

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +141 to +155
_hubbleMapLibPromise = import('maplibre-gl').then(module => {
const maplibre = (module as any).default || module;

class HubbleMapLibreMap extends maplibre.Map {
constructor(options: any) {
super(options);
patchMapLibreTransformForHubble((this as any).transform);
}
}

return {
...maplibre,
Map: HubbleMapLibreMap
};
});
Comment on lines +151 to +154
return {
...maplibre,
Map: HubbleMapLibreMap
};
Comment on lines +191 to +201
Object.defineProperty(transform, '_constrain', {
value() {},
writable: true,
configurable: true
});

Object.defineProperty(transform, '_calcMatrices', {
value() {},
writable: true,
configurable: true
});
Comment on lines +161 to +166
function patchMapLibreTransformForHubble(transform: any): void {
if (!transform) return;

if (transform.__hubbleCompatPatched) return;

addTransformSetter(transform, 'bearing', 'setBearing');
@lixun910
Copy link
Copy Markdown
Collaborator Author

hmm it seems the video quality is also bad (setting High quality) with maplibre v5:

kepler gl

@igorDykhta
Copy link
Copy Markdown
Collaborator

Screenshot 2026-05-13 at 8 39 42 PM

@lixun910 lixun910 marked this pull request as draft May 13, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants