make_map {webmap}R Documentation

Create a web map using TNM services

Description

Create a Leaflet map widget that includes base maps offered through The National Map (TNM) cached service endpoints. Information about the content of these base maps can be found within the TNM Base Maps document. TNM content is limited to the United States and territories. The map widget can be rendered on HTML pages generated from R Markdown, Shiny, or other applications.

Usage

make_map(
  maps,
  ...,
  protocol = c("WMTS", "WMS"),
  hydro = FALSE,
  collapse = FALSE
)

Arguments

maps

'character' vector. TNM base maps to include in the web map. Choices include "Topo", "Imagery", "Imagery Topo", "Hydrography", "Shaded Relief", and "Blank". See 'Details' section for a description of each base map. By default, all base maps are included. The one exception is the "Blank" map, which is only accessible using a Web Map Service (WMS), see protocol argument.

...

Arguments to be passed to the leaflet function.

protocol

'character' string. Standard protocol for serving pre-rendered georeferenced TNM map tiles. Select "WMTS" for the Web Map Tile Service (the default) and "WMS" for the Web Map Service.

hydro

'logical' flag. Whether to show or hide (the default) the "Hydrography" overlay base map.

collapse

'logical' flag. Whether the layers control should be rendered as an icon that expands when hovered over. Default is FALSE.

Details

Composite base maps include:

Value

An object of class 'leaflet', a hypertext markup language (HTML) map widget. See example for instructions on how to add additional graphic layers (such as points, lines, and polygons) to the map widget. Graphic layers added to the web map must be in latitude and longitude using WGS 84 (also known as EPSG:4326).

Author(s)

J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center

Examples

# Create map widget
map <- make_map()

# Print map widget
map

# Print map with markers
pts <- rbind(
  c(-112.049, 43.517),
  c(-122.171, 37.456),
  c( -77.367, 38.947),
  c(-149.803, 61.187),
  c( -80.248, 26.080)
)
leaflet::addMarkers(map,
  lng = pts[, 1],
  lat = pts[, 2]
)

# Print map of satellite imagery with a rectangle in the vicinity of UCLA
make_map(
  maps = "Imagery",
  collapse = TRUE
) |>
  leaflet::addRectangles(
    lng1 = -118.456,
    lat1 =   34.078,
    lng2 = -118.436,
    lat2 =   34.062,
    fillColor = "transparent"
  )

[Package webmap version 1.1.0 Index]