Skip to contents

R-CMD-check Browser tests pkgdown

leaflet.indoor adds multi-level indoor vector data and an accessible floor control to maps created with the R package leaflet. Each indoor data set displays exactly one active floor while remaining independent from other maps and indoor data sets on the same page.

Version 0.2.0 is experimental. The public API is tested for regression, but feedback from additional indoor data models is welcome.

Installation

Install version 0.2.0 from GitHub:

pak::pak("AurelienNicosiaULaval/leaflet-indoor@v0.2.0")

Git users can clone with SSH:

git clone git@github.com:AurelienNicosiaULaval/leaflet-indoor.git

Example

The included data are synthetic and do not describe a real building.

library(leaflet)
library(leaflet.indoor)

leaflet(
  indoor_demo,
  options = leafletOptions(crs = leafletCRS(crsClass = "L.CRS.Simple"))
) |>
  addIndoor(
    level = "level",
    initial_level = "0",
    layerId = ~feature_id,
    label = ~name,
    popup = ~description,
    style = list(fillColor = ~fill),
    crs = "simple"
  ) |>
  addIndoorControl(position = "bottomright")

For geographic sf data, addIndoor() transforms a declared CRS to EPSG:4326. For local Cartesian plans, use L.CRS.Simple, leave the sf CRS undefined, and set crs = "simple". No spatial transformation is invented for local coordinates.

See the getting started article for styles, multi-floor features, GeoJSON, coordinate systems, and Shiny.

Room photos

Associate room identifiers with images and plain-text captions using one row per photo. Repeating an identifier creates a carousel in catalogue order:

room_photos <- indoorPhotoCatalog(
  layerId = c("feature-01", "feature-01"),
  src = c("entrance.jpg", "windows.jpg"),
  caption = c("Entrance view", "View from the windows")
)

leaflet(indoor_demo, options = leafletOptions(
  crs = leafletCRS("L.CRS.Simple")
)) |>
  addIndoor(
    layerId = ~feature_id,
    photos = room_photos,
    popup = ~description,
    crs = "simple"
  ) |>
  addIndoorControl()

Existing local image files are embedded for portable saved widgets. Features without catalogue rows keep their ordinary popup. The Room photo carousels article provides a real-world demonstration using a Leaflet street map, 135 named Louvre indoor spaces from OpenStreetMap, and five public-domain photographs associated with three rooms on two floors. The Wikimedia Commons example includes complete provenance and is explicitly not an official visitor or safety plan.

Room comments and testimonials

Add one catalogue row per comment and attach it to a room’s layerId. Only rooms with comments receive an icon. Click the icon to read comments, or click the room to open its usual popup or photo carousel.

library(leaflet)
library(leaflet.indoor)

room_comments <- indoorCommentCatalog(
  layerId = "feature-01",
  text = "A fictional example of a visitor comment.",
  author = "Example visitor",
  title = "Fictional demonstration comment"
)

leaflet(indoor_demo, options = leafletOptions(
  crs = leafletCRS("L.CRS.Simple")
)) |>
  addIndoor(
    layerId = ~feature_id,
    label = ~name,
    popup = ~description,
    comments = room_comments,
    commentOptions = indoorCommentOptions(icon = "quote"),
    crs = "simple"
  ) |>
  addIndoorControl()

Choose "comment", "quote", "info", or a short text symbol with indoorCommentOptions(). Icons follow the active floor and support Enter, Space, and Escape. Optional author, date, source, and title fields preserve attribution; source links accept HTTP(S) URLs. The room-comments article extends the Louvre example with four attributed excerpts or summaries from three published visitor accounts in three rooms.

Shiny

Floor changes made by a user are available as input$MAPID_indoor_level. The value contains level, dataset_id, and control_id. Update a rendered map with:

Issues and security

Report reproducible problems through the GitHub issue tracker. Plain labels and popups are escaped. Use htmltools::HTML() only with trusted content.

This is an independent MIT-licensed implementation. It does not incorporate source code from Christopher Baines’s archived BSD-2-Clause leaflet-indoor JavaScript plugin, which established an earlier floor-layer and level-control pattern for Leaflet.