r-spatial / leafsync

Small Multiples for Leaflet Webmaps
Other
36 stars 2 forks source link

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

Open aito123 opened 2 years ago

aito123 commented 2 years ago

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

tim-salabim commented 2 years ago

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

aito123 commented 2 years ago

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.

aditya4196 commented 2 years ago

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.

mgm-cincy commented 10 months ago

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.