Project Description

This project is to demonstrate the maps via Leaflet function while display the designed widget via hosts like GitHub, RPubs or NeoCities. The webpage must contain the date which the document is created.

The Spin Off

My map will demonstrate my favorite spots from Taiwan where as the spots have the responsive coordinates to be displayed.

# Load leaflet library for setup.
library(leaflet)
## Warning: 套件 'leaflet' 是用 R 版本 4.1.3 來建造的
# Setup the geographic location.
lats<-c(25.122220, 24.382706,24.055471,23.259900)
lons<-c(121.864699,121.223305,120.432857,120.107972)

# Label the location and city vectors
places <-c('Ying Yang Sea', 'Snow Mountain', 'Lukang Old Street','Beimen Salt Field')
states <-c('New Taipei City', 'Taichung City', 'Changhua County','Tainan City')

# Accumulate all information in one data frame for plotting
tw_geo <- data.frame(lat=lats, lng=lons, places=places, states=states, citycolor=c("#40C589","#FCFE4C","#03088E","#ED0F68") )
# Execute the leaflet Setup while add necessary Setups 
tw_geo %>% 
  leaflet()%>%
  addTiles()%>%
  addCircleMarkers(color=tw_geo$citycolor, popup = tw_geo$places)%>% 
  addLegend(labels = states[1:4], colors = c("#40C589","#FCFE4C","#03088E","#ED0F68")) %>%
  addProviderTiles(providers$OpenStreetMap)
## Assuming "lng" and "lat" are longitude and latitude, respectively