output_map: Add a map to a webpage

View source: R/output_map.R

output_mapR Documentation

Add a map to a webpage

Description

Adds a Leaflet map to a webpage, based on specified or selected inputs.

Usage

output_map(shapes = NULL, overlays = NULL, color = NULL,
  color_time = NULL, dataview = NULL, id = NULL, click = NULL,
  subto = NULL, background_shapes = NULL, options = list(),
  overlays_from_measures = TRUE, tiles = list(url =
  "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", options = list(maxZoom
  = 19)), attribution = list(name = "OpenStreetMap", url =
  "https://www.openstreetmap.org/copyright"))

Arguments

shapes

A list or list of lists specifying GeoJSON files. Each list should have at least a url entry (the URL of the file), and will need a name entry (associating it with one of the site's datasets) if the site has multiple datasets. The file's features must each have a properties field containing an ID found in the data – by default this is assumed to be called "geoid", but this can be specified with an id_property entry in the list. For example shapes = list(name = "data", url = "https://example.com/shapes.geojson", id_property = "id"). A time entry can also specify different maps for the same dataset, based on the selected time, along with a resolution entry to specify how to match the year; either "decade" (default) or "exact".

overlays

additional layers to add to the map, based on the selected variable; a list or list of lists with entries at least for variable (name of the variable associated with the layer) and source (path to the layer file, or a list with entries including url and time). Entries can also include a filter entry, with a list or list of lists of conditions, including entries for feature (name of the feature on which to condition entity inclusion), operator, and value.

color

The name of a variable, or id of a variable selector, to be used to color polygons.

color_time

The ID of a selector to specify which timepoint of color to use.

dataview

The ID of an input_dataview component.

id

Unique ID for the map.

click

The ID of an input to set to a clicked polygon's ID.

subto

A vector of output IDs to receive hover events from.

background_shapes

The name of a dataset (shapes) to show within a selection, regardless of selected dataset. Useful to show lower-level regions within higher-level regions.

options

A list of configuration options, potentially extracted from a saved leaflet object (see Leaflet documentation).

overlays_from_measures

Logical; if TRUE, will look for overlay information in measurement information.

tiles

A list or list of lists containing provider information (see leaflet providers; e.g., list(url = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", options = list(maxZoom = 19))).

attribution

A list with tile attribution information to be included in a credits section. To add attributions to the map, include them in tile's options list.

Value

A character vector of the content to be added.

Examples

output_map()

uva-bi-sdad/community documentation built on Oct. 12, 2023, 1:18 p.m.