Skip to content

Conversation

@chrisgervang
Copy link
Collaborator

@chrisgervang chrisgervang commented Jan 20, 2026

Closes #9709

Summary

  • Adds a public Deck#getView(viewId) method that returns a View by its id
  • Updates getViewport in @deck.gl/mapbox deck-utils to use the new API instead of manually searching through deck.props.views
  • Adds tests for single view and multiple views cases

This extracts the view lookup logic that was previously duplicated, making it a proper part of the Deck public API.

Test plan

  • TypeScript compilation passes for modules/core and modules/mapbox
  • Unit tests pass (Deck#getView with single view, Deck#getView with multiple views)
  • Manual testing with MapboxOverlay

🤖 Generated with Claude Code


Note

Adds a public API to fetch a view by id and refactors mapbox integration to use it.

  • New deck.getView(viewId) in Deck with tests for single/multiple views
  • modules/mapbox/src/deck-utils.ts: getViewport now uses deck.getView(MAPBOX_VIEW_ID) instead of scanning deck.props.views; narrows type when setting nearZMultiplier
  • Docs (docs/api-reference/core/deck.md): document getView, and add/clarify getViews/getViewports sections

Written by Cursor Bugbot for commit 345dc2a. This will update automatically on new commits. Configure here.

const viewState = getViewState(map);
const {views} = deck.props;
const view =
(views && flatten(views).find((v: {id: string}) => v.id === MAPBOX_VIEW_ID)) ||
Copy link
Collaborator Author

@chrisgervang chrisgervang Jan 20, 2026

Choose a reason for hiding this comment

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

I thought the use of flatten was odd since I can't think of a case where you'd have nested arrays of views.. the type is

// view-manager.ts:18
export type ViewOrViews = View | View[] | null;

But, looks like ViewManager is likely just being defensive, or its an old pattern?

// view-manager.ts:268-269
private _setViews(views: View[]): void {
  views = flatten(views, Boolean); // why are views flattened?
  ...
}

Either way, calling deck.getView() maintains the same behavior since view manager already normalized the list.

Add a public `getView(viewId)` method to the Deck class that returns
a View by its id. This extracts the view lookup logic that was previously
duplicated in places like MapboxOverlay's deck-utils.

- Add `Deck#getView(viewId: string): View | undefined`
- Update `getViewport` in deck-utils to use the new API
- Add tests for single view and multiple views cases

Closes #9709

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@chrisgervang chrisgervang force-pushed the chrisgervang/viewport-from-map branch from aecfd6a to 345dc2a Compare January 20, 2026 23:05
@coveralls
Copy link

coveralls commented Jan 20, 2026

Coverage Status

coverage: 91.115%. remained the same
when pulling 345dc2a on chrisgervang/viewport-from-map
into 83ac412 on master.

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.

Add Deck#getView()

3 participants