Skip to content
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

Saving Mapview Locally that have HTML Widget Popups #471

Open
GMor10sen opened this issue Feb 16, 2024 · 2 comments
Open

Saving Mapview Locally that have HTML Widget Popups #471

GMor10sen opened this issue Feb 16, 2024 · 2 comments

Comments

@GMor10sen
Copy link

Hello! Hope everyone is having a great day. I'm sure this has already been addressed but I seem to have trouble saving my map as an html and having the pop ups that I created work.

Here is a quick example of an interactive pop up I made when I run the following

`
#current directory is C:/Users/some_confused_guy_on_github/Desktop/Project Little Out There/Room Tax Interative

date_chosen <- "2020-12-01" # Select the date

county_names <- unique(data$Counties) # Obtain all unique county names from the data
pop_up_collective <- list() # Make an empty list to hold plots
county_index <- 1 # Make an index to help save plots in proper order
html_paths <- c() # Create a list to store HTML file paths

Loop through each county to generate pop-ups

for (county in county_names) {
print(county) # Print the current county being processed
county_data <- subset(data, Counties == county) # Subset data for the current county
pop_up_for_specific_county <- generate_pop_up(county_data, date_chosen, county) # Generate pop-up for the specific county
print(pop_up_for_specific_county) # Print the pop-up (optional)
path1 <- file.path("C:/Users/some_confused_guy_on_github/Desktop/Project Little Out There/popup_graphs_folder", paste0(county_index, "_popup.html")) # Define the file path to save the HTML file
saveWidget(pop_up_for_specific_county, path1) # Save the pop-up as an HTML file
pop_up_collective[[county_index]] <- pop_up_for_specific_county # Store the pop-up in the collective list
html_paths <- c(html_paths, path) # Store the HTML file path in the list
county_index <- county_index + 1 # Increment the county index
}

images <- html_paths # Store the HTML paths in the images list (I tried doing something with this but couldn't seem to make it work)

#merged_df just has all the county location information and zcol gets the values from the date chosen

room_tax_inderactive_map <- mapview(merged_df, zcol = date_chosen, map.types = "CartoDB.Positron", popup = popupGraph(pop_up_collective, type = "html", height = 600, width = 600))
`
Popup HTML in R
No click on R

when I save the file locally however I get

image

Any advice/guidance is really appreciated and I apologize if this has already been solved. Thanks again :D

@tim-salabim
Copy link
Member

I think this is still an u resolved issue. I will have a look and get back to you as soon as I find the time.

@GMor10sen
Copy link
Author

Sounds good! Thank you @tim-salabim for your quick reply, in the meantime I hope your day goes smooth :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants