library(sf)
## Linking to GEOS 3.13.1, GDAL 3.11.0, PROJ 9.6.0; sf_use_s2() is TRUE
library(leaflet)
library(htmltools)

local_points <- st_read("Point_parc.geojson", quiet = TRUE)
local_points_wgs84 <- st_transform(local_points, crs = 4326)

wfs_judete_url <- paste0(
  "https://www.geo-spatial.org/geoserver/ows?",
  "service=WFS&version=2.0.0&request=GetFeature",
  "&typeName=geospatial:ro_judete_poligon",
  "&outputFormat=application/json",
  "&srsName=EPSG:4326"
)
ro_judete <- st_read(wfs_judete_url, quiet = TRUE)

browsable(
  print(
    leaflet() %>%
      addTiles(
    urlTemplate = "https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",
    attribution = '&copy; <a href="https://www.esri.com/">Esri</a> — Source: Esri, Maxar, Earthstar Geographics'
  ) %>%
      
      addPolygons(
        data = ro_judete,
        color = "#00FFFF",
        weight = 1.5,
        fillColor = "#00FFFF",  # HEX corect; rgba nu e acceptat
        fillOpacity = 0.3
      ) %>%
      
      addCircleMarkers(
        data = local_points_wgs84,
        radius = 6,
        color = "red",
        stroke = TRUE,
        fillOpacity = 0.8,
        popup = ~paste0("<b>", Denumire, "</b><br/>Tipul: ", tip)
      ) %>%
      
      addMarkers(
        lng = 26.248238035718796,
        lat = 47.647366449329425,
        popup = "<div style='width:320px; height:240px;'>
           <b>GIF animat:</b><br/>
           <img src='https://i.gifer.com/origin/b4/b4ca2973276d64fcfaab208dd917cb64_w200.gif' 
                style='width:90%; height:90%; object-fit: contain;'/>
         </div>"
      ) %>%
     
      setView(lng = 26.252415065785637, lat = 47.639393477416036, zoom = 13.5) %>%  
      addScaleBar(position = "bottomleft") %>%
      addControl("© Creat cu R", position = "bottomright")
  )
)