I’ve created a map using the library leafletin R. It basically locates :
- Hospital
- Railway Station
- Bus Stop
- Restaurant
I’ve displayed their icons accordingly to easily locate it. By clicking on the icon you will get the particular name and by clicking on it you will be forwarded to its equivalent wikipedia page(i’ve linked its wikipedia pages to just show the link feature). By zooming out/in you can see the clusters.
The map below displays it all:
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
## Assuming "lng" and "lat" are longitude and latitude, respectively
The code for this map is as shown below:
#Loading the required libraries.
library(leaflet)
library(dplyr)
place <- data.frame(name = "Hospital", "Bus Stop", "Railway Station", "Restaurant", lat = c(21.2000, 21.8341, 21.6521, 21.5051), lng = c(70.2020, 70.3762, 70.5432, 71.1234))
icon1 <- makeIcon(
iconUrl = "Hospital.png",
iconWidth = 25, iconHeight = 31
)
icon2 <- makeIcon(
iconUrl = "busstop.png",
iconWidth = 25, iconHeight = 31
)
icon3 <- makeIcon(
iconUrl = "railway.jpeg",
iconWidth = 25, iconHeight = 31
)
icon4 <- makeIcon(
iconUrl = "Restaurant.png",
iconWidth = 25, iconHeight = 31
)
iList <- iconList(icon1,icon2,icon3,icon4)
sites <- c(
"<a href = 'https://en.wikipedia.org/wiki/Hospital'>Hospital</a>",
"<a href = 'https://en.wikipedia.org/wiki/Bus_stop'>Bus Stop</a>",
"<a href = 'https://en.wikipedia.org/wiki/Railway'>Railway Station</a>",
"<a href = 'https://en.wikipedia.org/wiki/Restaurant'>Restaurant</a>")
map <- place %>% leaflet() %>% addTiles() %>% addMarkers(icon = iList, popup = sites, clusterOptions = markerClusterOptions())
map