library(leaflet)
rose <- read.csv("rose.csv")
names(rose)[1] <- "lat"
rose$pop <- c(paste("Population:", c(6,6,5,1,2,1,10,15,6),
                    "<br/>Color:",rose$col))
icon1 <- makeIcon(iconUrl = "icon-1.png",
                  iconWidth = 40, iconHeight = 40,
                  iconAnchorX = 20, iconAnchorY = 20)
icon2 <- makeIcon(iconUrl = "icon-2.png",
                  iconWidth = 40, iconHeight = 40,
                  iconAnchorX = 20, iconAnchorY = 20)
icon3 <- makeIcon(iconUrl = "icon-3.png",
                  iconWidth = 40, iconHeight = 40,
                  iconAnchorX = 20, iconAnchorY = 20)
icons <- iconList(icon1,icon2,icon3)
html_legend <- "<img src='https://raw.githubusercontent.com/catree1988/practicalmachinelearning/gh-pages/index_files/figure-html/icon-1.png'style='width:40px;height:40px;'> Amygdalus persica 'Duplex'<br/>
<img src='https://raw.githubusercontent.com/catree1988/practicalmachinelearning/gh-pages/index_files/figure-html/icon-2.png'style='width:40px;height:40px;'> Amygdalus davidiana<br/>
<img src='https://raw.githubusercontent.com/catree1988/practicalmachinelearning/gh-pages/index_files/figure-html/icon-3.png'style='width:40px;height:40px;'> Rosa chinensis"
rosemap <- rose %>% 
        leaflet() %>% 
        addTiles() %>% 
        addCircleMarkers(radius = 20, weight = 6, color = rose$col) %>% 
        addMarkers(popup = rose$pop, icon = icons[rose$icon]) %>% 
        addControl(html = html_legend, position = "bottomleft")
rosemap