Comments (5)
Thanks for the extra detail. And I've been meaining to revisit the viewState
logic / code so thanks for bringing this up. When I first implemented it I had a lot of issues getting it to work in both a shiny & non-shiny environment, and getting the map & layers to update correctly.
I'll try and set some time aside next week to look at this in more detail.
from mapdeck.
Thanks for the PR - now merged
from mapdeck.
Something in this commit causes the map to freeze, so I've reverted to the commit before this.
from mapdeck.
something else was wrong so I've fully reverted this
from mapdeck.
Hi @dcooley, first of all apologies for those half-baked PRs. This time I'll share my thoughts first. I've been digging about the intended behaviour of deck.gl when using either initialViewState or viewState props. Here are some of my interpretations of what's going on when using the initialViewState
prop:
- At creation the
viewState
object will simply be set to the inputinitialViewState
prop. - When using
initialViewState
, theonViewStateChange
callback called during controller interaction, is internally followed by an update to the internalviewState
here. This update will track changes to the viewState in a nested objectviewState[viewId]
. That way multiple views can save their own viewState independently. Most importantly, the current view state will be located in that nested object, instead of at the rootviewState
. Also theviewManager
will be updated. - Currently,
md_change_location
overwrites the internalviewState
throughsetProps({initialViewState})
effectively destroying the nested object created duringonViewStateChange
. - If a call to
md_change_location
is made after controller interaction, reading the values of theviewState
object will pick stale values of the view instead of the most current ones.
In order to avoid fully overwriting the viewState, the initialViewState prop could be set in md_change_location
as follows:
window[map_id + 'map'].setProps({
initialViewState: {
...window[map_id + 'map'].viewState,
[map_id]: {
longitude: currentLon,
latitude: currentLat,
zoom: currentZoom,
maxZoom: currentMaxZoom,
minZoom: currentMinZoom,
maxPitch: currentMaxPitch,
minPitch: currentMinPitch,
pitch: currentPitch,
bearing: currentBearing,
transitionInterpolator: transition === "fly" ? new deck.FlyToInterpolator() : new deck.LinearInterpolator(),
transitionDuration: duration,
controller: true}
}
});
As such, the current viewState for the map_id could be retrieved using viewManager.getViewState(), as follows:
currentViewState = window[map_id + 'map'].viewManager?.getViewState(map_id) || window[map_id + 'map'].viewState;
getViewState()
seems to be the safest approach. I'm not sure if after deck.gl 8+ the "default-view" viewId will even occur when the DeckGL views
prop defines views with id as it's done with mapdeck.
I hope this helps!
from mapdeck.
Related Issues (20)
- Dragging Javascript errors HOT 3
- Custom tile layer (slippy map) HOT 1
- mapdeck crashing in windows R 4.3.1 ... but not in R 4.1.3 HOT 1
- clear_bitmap() not working HOT 2
- Mapdeck inside golem shinyapp does not update! HOT 6
- add_text: --> Error: Must supply `x`, `y` and `text` attributes HOT 1
- Cesium Troubles HOT 6
- onClick events don't return layerId HOT 1
- Map crashes when hidden in multitab shiny app HOT 9
- Legend order is incorrect for factors HOT 2
- Support for updating pitch/zoom/bearing without specifying the location HOT 3
- quarto tabset and mapdeck HOT 7
- geoarrow + mapdeck HOT 2
- crosstalk support
- Return coordinates with map click event HOT 1
- Styling parameters in add_text()
- Change scatterplot colour on client side HOT 1
- map freezes HOT 2
- Upgrade to Deck.gl 9.0.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mapdeck.