leafsync icon indicating copy to clipboard operation
leafsync copied to clipboard

mapview::mapshot() and htmlwidgets::saveWidget() not working to export as .html

Open aito123 opened this issue 3 years ago • 4 comments

Hello i think this should be addressed:

i have two mapview or leaflet objects:

peru_sync<- sync(peru_mapa1, peru_mapa2)

and when i try to save them as a .html file this happens:

mapshot(peru_sync, url = "peru_mapa_sync.html")

Error in .getNamespace(pkg) : invalid type/length (symbol/0) in vector allocation

Help, thanks

aito123 avatar Oct 13 '21 04:10 aito123

Have you seen https://github.com/r-spatial/mapview/issues/35?

tim-salabim avatar Oct 13 '21 06:10 tim-salabim

Thanks for the reply Tim. I did see that post though it didn't work for my case scenario. I was looking for a option inside mapview package but i don't think there is.

Luckily i work around my problem and solve it. I haven't been able to export a sync html mapview in rscript but it is absolutely possible in Rmarkdown. But now my problem is that when i knit my .Rmd with my sync(map1, map2) argument i can't show it fullscreen. Like when you put in r chunk (l-screen) for a wide view. Any solution in that? Thanks for listening.

aito123 avatar Oct 14 '21 18:10 aito123

Hi, In the below code, final_map <- leafletProxy("second_stage_map", session) %>% clearControls() %>% clearGroup("selected_poly") %>% addProviderTiles(providers$Esri.NatGeoWorldMap) and then to save the map as an image mapshot(final_map, file=paste0(getwd(), '/exported_map.png'))

But it is giving me the below error Warning: Error in .getNamespace: invalid type/length (symbol/0) in vector allocation

Same error as the discussion in this thread above, Can anyone explain what exactly is this error, then it would be helpful for me to fix it.

aditya4196 avatar Apr 22 '22 03:04 aditya4196

I was facing the same issue as aito123. I synced my maps in RStudio and from the Viewer tab zoomed to the maps. Then from the Viewer tab when I chose export I saw an option "Save as Web Page". I chose that option, and a stand alone html was created, which allowed me to zoom and use pop-up features in the html. I am using RStudio version 2022.07.01 Build 554.

mgm-cincy avatar Sep 12 '23 13:09 mgm-cincy