-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.R
61 lines (53 loc) · 1.79 KB
/
server.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
server <- function(input, output) {
#--------------------------------------------------
# read data
dta <- openxlsx::read.xlsx(
"raw_data.xlsx"
)
# make it spatial
poi <- sf::st_as_sf(
dta,
coords = c("longitude", "latitude"),
crs = 4326,
remove = FALSE
)
#--------------------------------------------------
# replace picture link with path if picture is privat
poi <- poi |>
dplyr::mutate(
picture = dplyr::case_when(
source_ind == "privat" ~ paste0(name, ".JPG"),
TRUE ~ picture
)
)
#--------------------------------------------------
# define marker icons
pointerIcon <- makeIcon(
iconUrl = "pointer_large.png",
iconWidth = 40,
iconHeight = 40
)
#--------------------------------------------------
# define label text for pop-ups
label_text <- glue(
"<h3 style = \"font-family:Calibri, sans-serif;\"><b>{poi$name}</b></h3>",
"<p style = \"font-family:Calibri, sans-serif; font-size:140%; overflow-y:scroll; height:100px\">{poi$description}</p>",
"<img src={poi$picture} width = 300px height = auto>",
"<p style = \"font-family:Calibri, sans-serif;font-size:100%\">{poi$source}</p>"
)
#--------------------------------------------------
# create map
output$map <- renderLeaflet({
leaflet() |>
addProviderTiles(
providers$Esri.WorldTopoMap,
options = providerTileOptions(noWrap = TRUE)
) |>
setView(12.39071794006535, 51.345641678880185, zoom = 13) |>
addMarkers(
data = poi,
icon = pointerIcon,
popup = label_text
)
})
}