Skip to contents

Adds points, lines, and polygons organized by floor to a leaflet::leaflet() map. Exactly one floor is visible for each dataset_id.

Usage

addIndoor(
  map,
  data = leaflet::getMapData(map),
  level = "level",
  dataset_id = "indoor",
  level_order = NULL,
  initial_level = NULL,
  layerId = NULL,
  label = NULL,
  popup = NULL,
  style = NULL,
  options = indoorOptions(),
  labelOptions = leaflet::labelOptions(),
  popupOptions = leaflet::popupOptions(),
  missing_level = c("error", "drop"),
  crs = c("auto", "geographic", "simple"),
  photos = NULL,
  photoOptions = indoorPhotoOptions(),
  comments = NULL,
  commentOptions = indoorCommentOptions()
)

Arguments

map

A Leaflet map or proxy.

data

An sf, sfc, optional SpatVector, or GeoJSON object. The default uses the data supplied to leaflet::leaflet() or leaflet::leafletProxy().

level

For sf and GeoJSON, the floor column or property name. For a bare sfc, an explicit vector or list of floor values.

dataset_id

Non-empty identifier scoped to this map.

level_order

Optional vector containing every observed floor exactly once, from lowest to highest.

initial_level

Initial floor. The default is "0" when present, then the first floor in level_order.

layerId

Optional feature identifiers. Formulas are evaluated against data.

label, popup

Optional tooltip and popup content. Plain strings are escaped; wrap trusted markup in htmltools::HTML().

style

Optional named list of fixed, vector, or formula-driven Leaflet path options.

options

Options created by indoorOptions().

labelOptions, popupOptions

Leaflet tooltip and popup options.

missing_level

Either "error" or "drop".

crs

Coordinate interpretation. "auto" detects the map CRS for ordinary maps. Use "simple" explicitly for local coordinates sent to a proxy.

photos

Optional photo catalogue created by indoorPhotoCatalog(), or a data frame with equivalent layerId, src, caption, and optional alt columns. Catalogue identifiers must match layerId values.

photoOptions

Carousel labels created by indoorPhotoOptions().

comments

Optional catalogue created by indoorCommentCatalog(), or a data frame with equivalent columns. Identifiers must match layerId.

commentOptions

Icon and labels created by indoorCommentOptions().

Value

The input map or proxy, with an indoor method queued.

Examples

leaflet::leaflet(
  indoor_demo,
  options = leaflet::leafletOptions(
    crs = leaflet::leafletCRS("L.CRS.Simple")
  )
) |>
  leaflet::addMapPane("indoor", 420) |>
  addIndoor(
    initial_level = "0",
    layerId = ~feature_id,
    label = ~name,
    popup = ~description,
    crs = "simple",
    options = indoorOptions(pane = "indoor")
  ) |>
  addIndoorControl(position = "bottomright")