DataScienceHobart / 2017-02-03-graphics-imas

4 stars 2 forks source link

how to snapshot zoomed in leaflet #4

Open mdsumner opened 7 years ago

mdsumner commented 7 years ago

Tried this code, how to save as image zoomed into Macquarie Island?

library(orsifronts)  ## install. packages("orsifronts")
library(leaflet)        ## install.packages("leaflet")

## orsifronts is a SpatialPolygonsDataFrame (could be read via shapefile, or contoured from other data)
data(orsifronts)
fronts_as_points <- as(orsifronts, "SpatialPointsDataFrame")
fronts_as_points <- fronts_as_points[sample(nrow(fronts_as_points), 20), ]

leaflet() %>% leaflet::setMaxBounds(130, -60, 160,  -40) %>% 
  addProviderTiles(providers$Esri.NatGeoWorldMap) %>% 
  addPolylines(data = rmapshaper::ms_simplify(orsifronts), 
               color = ~colorFactor(viridis::viridis(nrow(orsifronts)), front)(front)) %>% 
  addMarkers(data = fronts_as_points, label = ~front,  labelOptions = labelOptions(noHide = TRUE))
mdsumner commented 7 years ago

@mdsumner hey, can we actually do this