class: center, middle, inverse, title-slide # Leaflet Package Presentation ## RStudio ### Javante Foster ### Due: 05/15/19, Wednes. --- background-image: url(http://www.brooklyn.cuny.edu/web/abo_misc/180827_Map_689x892.jpg) background-position: center background-size: contain --- class: inverse, center, middle # *Warning -- class: inverse, center, middle ### This is A Very Short, -- class: inverse, center, middle ### Simple, -- class: inverse, center, middle ### Basic, -- class: inverse, center, middle ### Bare-bones, -- class: inverse, center, middle ### Tutorial for Leaflet Package --- # What is the Leaflet package? - create interactive map - rstudio and shinyapp --- # Leaflet Package? - Download "leaflet"package from the library -- `Tools -> Install Packages -> leaflet`;<sup></sup> -- - Load the leaflet package ```r library(leaflet) ``` --- # From there? ## General Map --- ```r library(leaflet) leaflet() %>% addTiles() ```
--- # Map features? -- - addMarkers() -- - the longitute (lng), latitude (lat), and popup name --- ```r leaflet() %>% addTiles() %>% addMarkers(lng = -73.952533, lat =40.631021, popup="CUNY Brooklyn College") ```
--- # Markers - Changing Your Markers - addCircleMarkers([lng, lat]) --- Example: ```r leaflet() %>% addTiles() %>% addCircleMarkers(lng=-73.952533, lat=40.631021, popup="CUNY Brooklyn College") ```
--- ```r a <- runif(50,1,50) b <- runif(50,1,50) long_lat <- data.frame(a,b) leaflet(long_lat) %>% addTiles() %>% addCircleMarkers(lng = a, lat = b) ```
--- # Markers - Change Colors -- - addCircleMarkers(color = '[insert color]') --- ```r a <- runif(50,1,50) b <- runif(50,1,50) long_lat <- data.frame(a,b) leaflet(long_lat) %>% addTiles() %>% addCircleMarkers(a, b, color = 'fuchsia') ```
--- ```r a <- runif(50,1,50) b <- runif(50,1,50) long_lat <- data.frame(a,b) leaflet(long_lat) %>% addTiles() %>% addCircleMarkers(a, b, color = 'burgundy') ```
--- # Markers - Create Your Own Icons -- - makeIcon() - iconUrl = [insert website link here], - iconWidth = [create your own size #], iconHeight = [create your own size #]) --- ```r CUNYBC <- makeIcon( iconUrl = "https://upload.wikimedia.org/wikipedia/commons/6/6c/2016_Brooklyn_College_Library.jpg", iconWidth = 70, iconHeight = 70) leaflet() %>% addTiles() %>% addMarkers(lng=-73.953558, lat=40.631021, popup="CUNY Brooklyn College", icon = CUNYBC) ```
--- # Markers - Label Options, font, and font size -- - icon = CUNYBC, label = "Sup?", labelOptions = labelOptions(noHide = F, direction = "top", style = list("color" = "fuchsia","font-family" = "Snap ITC", "font-size" = "50px"))) --- ```r CUNYBC <- makeIcon( iconUrl = "https://upload.wikimedia.org/wikipedia/commons/6/6c/2016_Brooklyn_College_Library.jpg", iconWidth = 70, iconHeight = 70) leaflet() %>% addTiles() %>% addMarkers(lng=-73.953558, lat=40.631021, icon = CUNYBC, label = "Sup?", labelOptions = labelOptions(noHide = F, direction = "top", style = list("color" = "fuchsia", "font-family" = "Snap ITC", "font-size" = "50px"))) ```
--- # References - Leaflet for R. (2016). Retrieved from: https://rstudio.github.io/leaflet/ - Wikipedia, the free encyclopedia. (2019). Brooklyn College. Retrieved from: https://upload.wikimedia.org/wikipedia/commons/6/6c/2016_Brooklyn_College_Library.jpg - Wikipedia, the free encyclopedia. (2019). Brooklyn College Logo. Retrieved from: https://en.wikipedia.org/wiki/File:Brooklyn_College_Logo.svg --- background-image: url(https://upload.wikimedia.org/wikipedia/en/thumb/4/43/Brooklyn_College_Logo.svg/1024px-Brooklyn_College_Logo.svg.png) background-position: center background-size: contain # Please clap so I can leave!