frigos_localisation/leaflet.R

31 lines
660 B
R
Raw Normal View History

2022-01-15 13:38:33 -05:00
library("dplyr")
library("stringr")
library("sf")
library("leaflet")
library("htmltools")
library("htmlwidgets")
2022-01-14 12:38:39 -05:00
2022-01-15 13:38:33 -05:00
setwd("/home/francois/frigos_localisation")
2022-01-14 12:38:39 -05:00
2022-01-15 13:38:33 -05:00
frigo_table_sf <- read.csv("frigo_table.csv") %>%
st_as_sf(frigo_table3, coords = c("lon", "lat"))
2022-01-14 12:38:39 -05:00
2022-01-15 13:38:33 -05:00
if (file.exists("frigo_table_sf.geojson")){
file.remove("frigo_table_sf.geojson")
}
frigo_table_sf %>% write_sf("frigo_table_sf.geojson")
2022-01-14 12:38:39 -05:00
l <- leaflet(data = frigo_table_sf) %>%
addTiles() %>%
2022-01-15 13:38:33 -05:00
addMarkers(popup = ~paste0(
2022-01-14 12:38:39 -05:00
'<h2>',
Quoi,
'</h2><p>',
Adresse,
"</p>",
Particularités %>%
str_replace_all("\\n", "<br>")
))
2022-01-15 13:38:33 -05:00
saveWidget(l, file = "frigo_carte.html")