20  Mapping With plotly

20.1 Call Libraries

Show the code
library(plotly)

20.2 Set Geographic Parameters

Show the code
g <- list(showland = TRUE, 
          showcountries = TRUE,
          landcolor = toRGB("forestgreen"), # land color
          showocean = TRUE, # show ocean
          oceancolor = "lightblue", # ocean color
          # projection = list(type = 'robinson'),
          projection = list(type = 'orthographic',
                    rotation = list(lon = 0,
                                    lat = 0,
                                    roll = 0)))

20.3 Make a Map

Show the code
plot_geo() %>% 
  layout(title = "Demonstration Map", 
         geo = g)

20.4 scattermapbox

Show the code
plot_ly(type = "scattermapbox") %>%
  layout(
    mapbox = list(
      style = 'open-street-map',
      zoom = 6.0, # zoom
      center = list(lon = -83, lat = 42))) # centered on SE Michigan