library(leaflet)
library(htmltools)
# 1. Datele
puncte <- data.frame(
id = c("biserica", "casa", "plaja", "dunare"),
nume = c("Biserica Iani Melano", "Casa Tradițională", "Plaja Sălbatică", "Brațul Dunării"),
lat = c(44.8983, 44.8965, 44.8814, 44.9125),
lng = c(29.5857, 29.5892, 29.6062, 29.5532),
img = c("https://www.info-delta.ro/wp-content/uploads/2022/02/sfantu-gheorghe39.jpg",
"https://www.turistulliber.ro/wp-content/uploads/2021/06/cherhanaua-veche-sfantu-gheorghe-1024x768.jpg",
"https://www.info-delta.ro/wp-content/uploads/2022/02/sfantu_gheorghe_aerian5.jpg",
"https://www.info-delta.ro/wp-content/uploads/2022/02/sfantu_gheorghe_aerian3.jpg")
)
# 2. Crearea panoului (Legendă/Control)
# Am stilizat div-ul pentru a arăta exact ca cel din imaginea ta
panou_control <- tags$div(
style = "background: rgba(255, 255, 255, 0.95); padding: 15px; border-radius: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.2);",
tags$h3("Explorare Sf. Gheorghe", style = "margin: 0 0 10px 0; color: #2c3e50; border-bottom: 2px solid #27ae60;"),
tags$div(
tags$b("Strat de Bază:"), tags$br(),
"OSM & OpenTopoMap" # Leaflet gestionează automat switch-ul de straturi sus-dreapta
),
tags$br(),
tags$div(
tags$b("Legenda:"), tags$br(),
tags$ul(style = "list-style-type: none; padding-left: 0;",
tags$li(tags$span("●", style="color:red;"), " Obiective Turistice")
)
)
)
# 3. Generarea hărții
harta <- leaflet(data = puncte) %>%
addTiles(group = "Hartă Standard (OSM)") %>%
addProviderTiles(providers$OpenTopoMap, group = "Hartă de Relief") %>%
addMarkers(~lng, ~lat,
popup = ~paste0("<b>", nume, "</b><br><img src='", img, "' width='200px'>")) %>%
addLayersControl(
baseGroups = c("Hartă Standard (OSM)", "Hartă de Relief"),
options = layersControlOptions(collapsed = FALSE)
) %>%
addControl(html = panou_control, position = "topright") %>%
setView(lng = 29.588, lat = 44.895, zoom = 13)
# 4. Afișare
harta