-
Notifications
You must be signed in to change notification settings - Fork 0
/
DDP_W2_R2.r
36 lines (30 loc) · 1.32 KB
/
DDP_W2_R2.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
---
title: "DDP_W2_R_Leaflet_output"
author: "T Sathiyanarayanan"
date: "27 May 2024"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(leaflet)
library(htmlwidgets)
# Create the map object and add the default OpenStreetMap tiles
map <- leaflet() %>%
addTiles()
# Define the icon for Benrath Palace
benrathPalaceIcon <- icons(
iconUrl = "http://www.schloss-benrath.de/fileadmin/_processed_/csm_corps-de-logis-blumen_2e04b2b859.jpg",
iconWidth = 30*408/255, iconHeight = 30,
iconAnchorX = 30*408/255/2, iconAnchorY = 30/2
)
# Define the popup content for Benrath Palace
benrathPalacePopup <- c("<a href='http://www.schloss-benrath.de/welcome/?L=1'>Benrath Palace<br><img src='http://www.schloss-benrath.de/fileadmin/_processed_/csm_corps-de-logis-blumen_2e04b2b859.jpg' width='210' height='132' alt='Foto Corps de Logis' title='Foto Corps de Logi'></a>")
# Add the marker with the custom icon and popup to the map
map <- map %>%
addMarkers(lat = 51.161027, lng = 6.870550, popup = benrathPalacePopup, icon = benrathPalaceIcon)
# Print the map
map
# Save the map as an HTML file with the current date in the filename
current_date <- Sys.Date()
html_filename <- paste0("leaflet_map_", current_date, ".html")
saveWidget(map, file = html_filename)