Skip to content

Conversation

@charlieforward9
Copy link
Contributor

@charlieforward9 charlieforward9 commented Dec 31, 2025

Background

exports classes helpful for extending MapViewState in dependent repos

Change List

  • add MapState and MapStateProps to index.ts
  • add MapState and MapStateProps documentaiton
@chrisgervang
Copy link
Collaborator

chrisgervang commented Jan 1, 2026

These classes go way back - #986 discusses them, this RFC mentions them - and yet, they have never been exported. I'm curious if there was a reason for this decision?

@charlieforward9 could you share more about your use case, and how you intend to use these in your own application? I'm guessing it to help users implement custom controllers.

Is there any reason we wouldn't export the other *State classes as well?


See the `Controller` class [documentation](./controller.md#methods) for the methods that you can use and/or override.

## MapState
Copy link
Collaborator

Choose a reason for hiding this comment

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

Each class is typically documented in their own file, however these classes are meant to always be composited into controllers, so this organization could make sense.

It'd be great to have the custom controller example expanded to include the application of this class and https://deck.gl/docs/api-reference/core/controller#example-implementing-a-custom-controller to mention ViewState

@charlieforward9
Copy link
Contributor Author

@chrisgervang Thanks for getting to this, and Happy New Year.

Exactly, my use case is implementing my own typesafe controllers optimized for mobile interactivity.

Specifically, I need:

  • two finger + vertical drag pitch
  • double tap + vertical drag zoom

I'd be happy to contribute this as default controller functionality, but to start I am trying to implement within my app as I have the mobile testing commands working and find it easier to implement outside of the deck.gl repo than within.

Interested in your thoughts on this.

Comment on lines +73 to +92
### Usage

```js
import {MapState} from '@deck.gl/core';

// Create a MapState instance
const mapState = new MapState({
width: 800,
height: 600,
latitude: 37.7749,
longitude: -122.4194,
zoom: 11,
bearing: 0,
pitch: 0,
makeViewport: (props) => new WebMercatorViewport(props)
});

// Use MapState methods
const newState = mapState.pan({pos: [100, 100]});
const zoomedState = mapState.zoom({pos: [400, 300], scale: 2});
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think these classes are intended to be used directly like this - rather, they are to be implemented and the Controller uses them. My current understanding is these are for helping users implement extensions of core controllers:

class CustomState extends MapState {

}

class CustomController extends MapController {
  ControllerState = CustomState
}

Usage docs along these lines makes more sense then showing direct function calls

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

Labels

None yet

2 participants