-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix(core): export MapState and MapStateProps #9929
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
base: master
Are you sure you want to change the base?
Conversation
|
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 |
|
|
||
| See the `Controller` class [documentation](./controller.md#methods) for the methods that you can use and/or override. | ||
|
|
||
| ## MapState |
There was a problem hiding this comment.
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
|
@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:
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. |
| ### 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}); |
There was a problem hiding this comment.
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
Background
exports classes helpful for extending MapViewState in dependent repos
Change List