Skip to content
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

feat(mapbox): support Maplibre globe projection #9296

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Pessimistress
Copy link
Collaborator

For #9199

Note: requires #9295

Tested for overlaid and interleaved modes

Change List

  • MapboxOverlay switches views based on map projection mode

@coveralls
Copy link

coveralls commented Dec 12, 2024

Coverage Status

coverage: 91.677% (-0.03%) from 91.702%
when pulling 6a24007 on x/mapbox-overlay-globe
into e9eada6 on master.

@@ -58,6 +58,10 @@ export type GlobeViewportOptions = {
nearZMultiplier?: number;
/** Scaler for the far plane, 1 unit equals to the distance from the camera to the edge of the screen. Default `1` */
farZMultiplier?: number;
/** Optionally override the near plane position. `nearZMultiplier` is ignored if `nearZ` is supplied. */
Copy link
Collaborator

Choose a reason for hiding this comment

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

A bit nervous about having these overrides, especially as nearZ and nearZMultiplier do the same thing. Should we issue a warning if both are supplied?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree this can be confusing (and wasn't an easy thing to catch when I was first learning it). FWIW, web-mercator-viewport has had these same overrides for a long time.

A warning would be nice.. the multipliers have defaults assigned, so we'd just need to assign those after checking the user-supplied values (or else, they'd always print).

Copy link
Collaborator

Choose a reason for hiding this comment

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

This does look confusing and somewhat intimidating. I think these props were originally intended as a semi-undocumented escape hatch but now I seem to see these being "touched" in every PR...

If not a coincidence, might be good to audit this API with an eye towards making it as fail proof as possible for new (and old) users.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@ibgreen FWIW I was not changing them in my PR, that was just due to github getting confused. See updated PR

modules/mapbox/src/deck-utils.ts Outdated Show resolved Hide resolved
if (type === 'globe') {
return 'globe';
}
return 'mercator';
Copy link
Collaborator

Choose a reason for hiding this comment

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

warn when type is not mercator?


export function getDefaultView(map: Map): GlobeView | MapView {
if (getProjection(map) === 'globe') {
return new GlobeView({id: 'mapbox'});
Copy link
Collaborator

Choose a reason for hiding this comment

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

Detect maplibre and instead call view 'maplibre'? Or choose a common name like 'map-overlay'?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We don't have a reliable way to detect mapbox vs maplibre, given that we also support a wide range of versions of each library.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree it's not the best name. Unfortunately, this is used in some edge cases... @chrisgervang

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it a question of whether this would be a breaking change for the multi-view edge cases?

// @ts-ignore (2345) map is always defined if deck is
deck.setProps({viewState: getViewState(this._map)});
const map = this._map;
if (deck && map) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it is actually better to crash if our assumption is that map is defined is invalid

Copy link
Collaborator

@chrisgervang chrisgervang left a comment

Choose a reason for hiding this comment

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

Exciting support!

There's a lot of branching to support different API versions... at some point it'll be cleaner to maintain (and document) as two modules. But this is probably fine for 9.1

// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors

import {MapboxOverlay as DeckOverlay} from '@deck.gl/mapbox';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why rename/alias things? If we are not happy with the name, rename it at export? If trying to make code clearer a longer name might be needed? Any name that mentions either just Deck or Mapbox is going to be confusing

@@ -58,6 +58,10 @@ export type GlobeViewportOptions = {
nearZMultiplier?: number;
/** Scaler for the far plane, 1 unit equals to the distance from the camera to the edge of the screen. Default `1` */
farZMultiplier?: number;
/** Optionally override the near plane position. `nearZMultiplier` is ignored if `nearZ` is supplied. */
Copy link
Collaborator

Choose a reason for hiding this comment

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

This does look confusing and somewhat intimidating. I think these props were originally intended as a semi-undocumented escape hatch but now I seem to see these being "touched" in every PR...

If not a coincidence, might be good to audit this API with an eye towards making it as fail proof as possible for new (and old) users.

This was referenced Dec 13, 2024
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.

5 participants