Leaflet Markers don't show up in viewer zoom

Hi R community,

When I click on the zoom viewer the markers of the leaflet map disappear. What is the reason?
Also I would like to embed that MAP into a blog post. I saved locally the leaflet map into an HTML format in the static folder of my Hugo website.
I have no idea what code used to insert this map into the markdown.

I tried with that piece of code but it didn't work.

"<iframe seamless
src="/static/leaflet/leafmap.html" width="100%" height="500"></iframe>" 

my reprex()


library(tidyverse)
#> Warning: le package 'ggplot2' a été compilé avec la version R 3.6.3
#> Warning: le package 'tidyr' a été compilé avec la version R 3.6.3
#> Warning: le package 'dplyr' a été compilé avec la version R 3.6.3
library(ggplot2)
library(readxl)
library(sf)
#> Warning: le package 'sf' a été compilé avec la version R 3.6.2
#> Linking to GEOS 3.6.1, GDAL 2.2.3, PROJ 4.9.3
library(leaflet)
#> Warning: le package 'leaflet' a été compilé avec la version R 3.6.2
library( htmltools )
library(htmlwidgets)
library(htmltools)


volcans=read_excel(path = "volcans.xlsx",range = "B2:K1572")

volcans=select(volcans,-Latitude,-Longitude,Longitude,Latitude)

volcans_sf=st_as_sf(volcans,coords = c("Longitude","Latitude"))
names(volcans_sf)[2]="Volcano_Name"

#REPLACE CODE BY ERUPTION TIME
volcans_sf$Eruption=str_replace(volcans_sf$Eruption, "Unknown", "Not Known")
volcans_sf$Eruption=str_replace(volcans_sf$Eruption, "D1", "1964 or later")
volcans_sf$Eruption=str_replace(volcans_sf$Eruption, "D2", "1900-1963")
volcans_sf$Eruption=str_replace(volcans_sf$Eruption, "D3", "1800-1899")
volcans_sf$Eruption=str_replace(volcans_sf$Eruption, "D4", "1700-1799")
volcans_sf$Eruption=str_replace(volcans_sf$Eruption, "D5", "1500-1699")
volcans_sf$Eruption=str_replace(volcans_sf$Eruption, "D6", "A.D. 1-1499")
volcans_sf$Eruption=str_replace(volcans_sf$Eruption, "D7", "B.C. (Holocene)")
volcans_sf$Eruption=str_replace(volcans_sf$Eruption, "U", "B.C. (Holocene)")
volcans_sf$Eruption=str_replace(volcans_sf$Eruption, "Q", "Quaternary eruption(s)")

volcanicon=makeIcon(
  iconUrl = "volcan.png",
50,50
)

content=paste("<b>",volcans_sf$Volcano_Name,"</b>","<br/>",
              "<p>Elevation:",volcans_sf$Elev,"m<p/>",
              "<p>Last Eruption:",volcans_sf$Eruption,"<p/>"
              )
  
leafletMap=leaflet(volcans_sf) %>% 
  addTiles() %>% 
  addMarkers(icon=volcanicon,label =lapply(content,HTML),
             labelOptions = labelOptions(style=list("font-size" = "15px"))) %>% 
  setView(lng = -87, lat = 11, zoom = 6)
leafletMap

currentWD <- getwd()
dir.create("D:/Hugo/bin/mysite/static/leaflet", showWarnings = FALSE)
setwd("D:/Hugo/bin/mysite/static/leaflet")
saveWidget(leafletMap, "leafMap.html")
setwd(currentWD)

snap

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.