-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
set_style() reverts back to original map in shiny #39
Comments
Hi Ben! Yes, this is a limitation of Mapbox GL JS and MapLibre's Here's a discussion: https://docs.mapbox.com/mapbox-gl-js/example/style-switch/ I thought I could handle this on the Shiny side but I haven't found a solution yet. I may need to implement internally in the package, where |
Hi Kyle, thanks for that explanation! That's not a problem then, I can come up with a workaround to make sure that the right data is shown when changing the style. One thing that might help me solve this is being able to initialize the map in a very basic form without any data, and then update it immediately during the initialization of the app using mapboxgl_proxy. At the moment I can't get the proxy to work on initialization, see example below where the proxy codes seems to get run but it does not affect the map.
Have you got a workaround for this by any chance? |
I had another crack at this today and have come up with a solution that seems to work. Initialisation and changing input$select_polygon:
Changing input$select_style:
A couple of things would be really nice to finish this off. If we could get the bearing and pitch as input values from the map (the same way the zoom and bbox can be retrieved), then the exact map view could be replicated upon changing the style even in cases where the user has changed these. I might have a crack at this in a PR soon if that sounds like it's worth doing?
|
Thank you! I do think we should handle this internally for users so you don't have to jump through all those hoops. Basically, when |
Hi Kyle,
I'm looking to update the basemap style using
mapboxgl_proxy()
andset_style()
in a shiny app. The style changes fine, but the map seems to revert back to the original data that was displayed when it was first rendered.For instance, in the reprex below, if you choose a different polygon and then update the style to "satellite-streets", the polygon and label data will disappear altogether at first, but when changing the style back to "standard" will revert back to the data that was initially provided to
renderMapboxgl()
.Ideally I'd like
set_style()
to just change the basemap without affecting any of the data that's loaded:I'm using the dev version of mapgl that I downloaded yesterday. Any solution would be much appreciated! Thanks in advance!
The text was updated successfully, but these errors were encountered: