Leaflet Maps

Leaflet is great

library("tidyverse")
library("sf")
library("leaflet")
library("leaflet.extras")

Stylised Oceania with Big Quakes

We designed this map together. Let’s import our data

quakes_sf <- quakes %>%
  st_as_sf(coords = c("long", "lat")) %>%
  st_set_crs(4326)

world_shapefiles <- read_sf("data/world-shape-files",
                            layer = "ne_110m_admin_0_countries")

oceania_shapefiles <- world_shapefiles %>%
  filter(CONTINENT == "Oceania")

And here’s the map:

quakes_sf %>%
  filter(mag > 6) %>%
  leaflet() %>%
  addCircleMarkers(color = "orange",
                   opacity = 1,
                   radius = 4,
                   label = ~paste("Magnitude:", as.character(mag))) %>%
  addPolygons(data = oceania_shapefiles,
              color = "black",
              fillColor = "brown",
              fillOpacity = 1,
              opacity = 1,
              weight = 2,
              label = ~NAME,
              popup = ~paste("Country:", NAME)) %>%
  addScaleBar(
    position = c("topright"),
    options = scaleBarOptions()
  ) %>%
  setMapWidgetStyle(style = list(background = "#aacbff"))

Clustered circle markers

quakes_sf %>%
  leaflet() %>%
  addProviderTiles(providers$Esri.OceanBasemap) %>%
  addCircleMarkers(clusterOptions = markerClusterOptions())