Map of Toronto

This assignment shows a map of downtown Toronto created with the R leaflet package. A standard marker is placed at city hall with the label of Toronto when mouse is hovered over it. Also, some circle markers were added to show subway station locations in the area. The stations on the Yonge and University subway lines are shown as red and blue circle markers, respectively.
Union Station connects both lines, so the overlap of the circle markers creates a purple marker. The name of each subway station is shown when you hover the mouse over one of the circle markers.A legend is also provided showing the Yonge and University line stations.

library(leaflet)
## Warning: package 'leaflet' was built under R version 3.4.3
yonge_subway_stations <- data.frame(lat =c(43.6491,43.6525,43.656389,43.661389, 43.645556),
                              lng = c(-79.3781,-79.379167,-79.38033,-79.383056,-79.380556))

uni_subway_stations <- data.frame(lat = c(43.647778,43.650833,43.654722,43.66,43.645556),
                          lng = c(-79.384722,-79.386667,-79.388333,-79.390556,-79.380556))



toronto_map <- leaflet() %>% addTiles() %>%
  addAwesomeMarkers(lat=43.6532, lng=-79.3832, label = "Toronto (best city around)", 
             labelOptions=labelOptions(noHide=F, direction = "left", offset = c(50,0),
                          textsize="14px",
             style = list("color" = "magenta",
                          "font-family"="serif",
                          "font-style"="italic",
                          "border-color" = "rgba(1,1,1,0.1)"))) %>%
  addCircleMarkers(yonge_subway_stations$lng, yonge_subway_stations$lat, color = 'red', 
                   label = c("King","Queen","Dundas","College", ""),
                   labelOptions=labelOptions(noHide = F)) %>%
  addCircleMarkers(uni_subway_stations$lng,uni_subway_stations$lat, color = 'blue',
                   label = c("St. Andrew", "Osgoode", "St.Patrick", "Queens Park", "Union"),
                   labelOptions = labelOptions(noHide=F)) %>%
  addLegend(labels = c("Yonge line", "University line"), colors = c("red", "blue"))

toronto_map