Leaflet

Package description

Map Provider

#Basic map with 

leaflet() %>% 
  addProviderTiles(providers$Thunderforest.Outdoors)
# If want list
providers <- providers


#3 from http://rpubs.com/bhaskarvk/leaflet-providers

m <- leaflet() %>% setView(lng=-80,lat=40,zoom=5) %>%   # nothing showing until we set providers
      addProviderTiles(providers$CartoDB.Positron)
      
# Take out ESRI provided tiles - leaves the 11 esri ones there
esri <- providers %>%              #List of all providers with their variations https://github.com/leaflet-extras/leaflet-providers/blob/master/leaflet-providers.js
  purrr::keep(~ grepl('^Esri',.))  ## similar to filter

esri %>%
  purrr::walk(function(x) m <<- m %>% addProviderTiles(x,group=x))  #walk Apply a function to each element of a vector  ## not sure what this does though


## this produces a nice set of options stacked  in top-right corner
m %>%
  addLayersControl(
    baseGroups = names(esri),
    options = layersControlOptions(collapsed = TRUE)
  )

0.1 Labels

leaflet() %>% addTiles() %>%
  addMarkers(
    lng=-118.456554, lat=34.078039,
    label='This is a label') 
# McDonald locations
macs %>% 
  head(100) %>% 
leaflet() %>% setView(lng=-80,lat=40,zoom=5) %>%   # nothing showing until we set providers
      addProviderTiles(providers$Esri.WorldStreetMap) %>% 
  addMarkers(lng = ~lng,lat = ~lat, popup= ~info)