-
Notifications
You must be signed in to change notification settings - Fork 41
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
On update forced to previous view #137
Comments
Thanks for reporting. I can't see what's triggering it to update the view so I'll need to investigate. |
this is the line function md_update_layer( map_id, layer_id, layer ) {
var elem = md_findObjectElementByKey( window[map_id + 'map'].props.layers, 'id', layer_id );
if ( elem != -1 ) {
window[ map_id + 'layers'][elem] = layer;
} else {
window[map_id + 'layers'].push( layer );
}
window[map_id + 'map'].setProps({ layers: [...window[map_id + 'layers'] ] });
} I don't know why updating a layer causes the map to re-focus back to its starting location. This may be a |
same behaviour in v7.0.0-beta |
I've just committed a temporary fix to the master branch. I'm not completely convinced it's fully fixed yet so will keep this issue open until I've done more testing. |
A side effect of [https://github.com/SymbolixAU/mapdeck/commit/c723bacbde18c710a5555f6a1c701b358cc59ff5] is when you remove a layer it will re-focus back to the starting state of the map library(shiny)
library(shinydashboard)
library(mapdeck)
ui <- dashboardPage(
dashboardHeader()
, dashboardSidebar(
actionButton(inputId = "roads", label = "roads")
)
, dashboardBody(
mapdeckOutput(outputId = "map")
)
)
server <- function(input, output) {
## initialise a map
output$map <- renderMapdeck({
mapdeck(
# location = c(144.9, -37)
# , zoom = 5
)
})
## use an observer to add and remove layers
observeEvent({input$roads},{
if ( input$roads %% 2 == 1 ) {
mapdeck_update(map_id = "map") %>%
add_path(
data = roads
, layer_id = "myRoads"
, stroke_colour = "RIGHT_LOC"
, update_view = T
)
} else {
mapdeck_update(map_id = "map") %>%
clear_path(layer_id = "myRoads")
}
})
}
shinyApp(ui, server) When adding the roads, the map focuses on the layer. When they are cleared, it goes back to starting state. The saga continues... |
only IFF the user hasn't interacted with the map! in the shiny example above, if you don't interact with the map between button presses, the |
@zacdav have you had a chance to test the latest dev version? |
@dcooley I'll have a go tomorrow on the example I had previously. |
@SymbolixAU @dcooley |
ok thanks. I'll close this now, but may reopen in the future if it's still not right. |
I'm currently using mapdeck to show some data in various cities, to facilitate this I've got a dropdown which triggers a view change to the specified location with some parameters. This works great, however, when you zoom in or pan and then update the data, the view is forced back to the original view of that location.
I've provided an application which demonstrates this, if you select Melbourne, zoom in, and hit refresh, it will transition back to the view.
Is there any way to avoid this behaviour? I've tried what seems to be most permutations of the parameters for the View/Zoom and layers but can't seem to get what I'm after.
Thanks
TODO
revert back to 6.4.0 (or older versions) to see if the issue replicates- nopeviewState
in stead ofinitialViewState
The text was updated successfully, but these errors were encountered: