library(leaflet)
library(magrittr)
library(sp)
library(htmltools)
biketheft = read.csv("~/Downloads/Lab7/biketheft.csv")

biketheft$Longitude <- as.numeric(biketheft$Longitude)
biketheft$Latitude <- as.numeric(biketheft$Latitude)

bikeicon <- makeIcon(iconUrl = "bikeicon.png",
                     iconWidth = 34, iconHeight = 50,
                     iconAnchorX = 17, iconAnchorY = 48)

leaflet() %>%
  addTiles() %>%
  addMarkers(data = biketheft, 
             lng = ~Longitude, 
             lat = ~Latitude,
             icon = bikeicon,
             clusterOptions = markerClusterOptions(showCoverageOnHover = FALSE),
             popup = ~paste("<b>Neighborhood:</b>",Neighbourhood,
                            "<br /><b>Address:</b>",Hundred_Block,
                            "<br /><b>Date (Y/M/D):</b>",Date,
                            "<br /><b>Time (Hr:Min):</b>",Time,
                            "<br /><b>Crime Type:</b> Bike Theft")) %>%
  addControl(position = "bottomright", 
             HTML("<p style='width: 235px; font-size:8pt; color:black; margin:0px'>
      <b>Author:</b> Adrienne Tang
      <br /><b>Data Source:</b> <a href='https://geodash.vpd.ca/opendata/'>VPD Data Portal</a> (2022)
      <br />GEOS 372 | Lab Section: L2B</p>")) %>%
  addLegend(position = "bottomright", 
            colors = c("#91d467","#ebc83d","#f68f42"), 
            labels = c("< 10", "< 100", "100+"), 
            opacity = 1,
            title = "Number of Bike Thefts")