| Title: | Multi-Level Indoor Maps with 'Leaflet' |
|---|---|
| Description: | Adds accessible floor controls and multi-level indoor vector layers to maps created with the 'leaflet' package. Simple features, GeoJSON, simple feature geometry collections, and optional 'SpatVector' objects can be displayed with one active floor per indoor data set. Room identifiers can also be associated with portable photo carousels whose images remain paired with plain-text captions. Optional room comments and attributed testimonials open from customizable, accessible map icons. |
| Authors: | Aurélien Nicosia [aut, cre] |
| Maintainer: | Aurélien Nicosia <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.0 |
| Built: | 2026-10-19 20:57:17 UTC |
| Source: | https://github.com/AurelienNicosiaULaval/leaflet-indoor |
Adds points, lines, and polygons organized by floor to a leaflet::leaflet()
map. Exactly one floor is visible for each dataset_id.
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() )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() )
map |
A Leaflet map or proxy. |
data |
An |
level |
For |
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 |
layerId |
Optional feature identifiers. Formulas are evaluated against
|
label, popup
|
Optional tooltip and popup content. Plain strings are
escaped; wrap trusted markup in |
style |
Optional named list of fixed, vector, or formula-driven Leaflet path options. |
options |
Options created by |
labelOptions, popupOptions
|
Leaflet tooltip and popup options. |
missing_level |
Either |
crs |
Coordinate interpretation. |
photos |
Optional photo catalogue created by |
photoOptions |
Carousel labels created by |
comments |
Optional catalogue created by |
commentOptions |
Icon and labels created by |
The input map or proxy, with an indoor method queued.
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")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")
Add an accessible floor control
addIndoorControl( map, dataset_id = "indoor", control_id = dataset_id, position = "topright", options = indoorControlOptions() )addIndoorControl( map, dataset_id = "indoor", control_id = dataset_id, position = "topright", options = indoorControlOptions() )
map |
A Leaflet map or proxy. |
dataset_id |
Indoor data set controlled by these buttons. |
control_id |
Unique control identifier scoped to this map. |
position |
One of |
options |
Options created by |
The input map or proxy.
Removes all features for one dataset_id. Linked controls remain present
and show their configured empty state.
clearIndoor(map, dataset_id = "indoor")clearIndoor(map, dataset_id = "indoor")
map |
A Leaflet map or proxy. |
dataset_id |
Indoor data set to clear. |
The input map or proxy.
A synthetic, freely reusable indoor plan created for package examples and
tests. It does not describe a real building. The mixed sf object contains
points, lines, polygons, and multiple geometries. Its level list-column
includes an elevator and stairs assigned to several floors.
indoor_demoindoor_demo
An sf object with 10 features and 7 variables:
Stable synthetic feature identifier.
Short feature label.
Popup-ready description.
Feature category.
Suggested fill color.
List-column of floor values.
Local Cartesian geometry with an undefined CRS.
Generated by data-raw/indoor_demo.R.
A geographic companion to indoor_demo, constructed directly in EPSG:4326 for offline examples. It is synthetic and does not describe a real building.
indoor_demo_geoindoor_demo_geo
An sf object with the same attributes and geometry types as
indoor_demo, using EPSG:4326.
Generated by data-raw/indoor_demo.R.
Each row associates a plain-text comment with a feature identifier supplied
to addIndoor(). Repeating an identifier displays several comments in row
order. Comments open from a separate map icon, leaving room popups and photo
carousels available through the room itself.
indoorCommentCatalog( layerId, text, author = "", date = "", source = "", title = "" )indoorCommentCatalog( layerId, text, author = "", date = "", source = "", title = "" )
layerId |
Feature identifiers matching |
text |
Non-empty plain-text comments. |
author, date
|
Optional plain-text attribution and date labels. An empty string omits the field. Dates are displayed as supplied. |
source |
Optional absolute HTTP(S) source URLs, or empty strings. |
title |
Optional plain-text headings, for example to distinguish a published excerpt from a summary. |
Fields of length one are recycled to the number of comments.
Content is rendered as text, including strings wrapped in HTML().
Authors are responsible for permission and accurate attribution when
displaying third-party material.
A data frame of class leaflet_indoor_comments.
comments <- indoorCommentCatalog( layerId = c("room-01", "room-01"), text = c("A quiet place to read.", "The entrance is easy to find."), author = c("Example visitor A", "Example visitor B") ) commentscomments <- indoorCommentCatalog( layerId = c("room-01", "room-01"), text = c("A quiet place to read.", "The entrance is easy to find."), author = c("Example visitor A", "Example visitor B") ) comments
Options for room comment icons
indoorCommentOptions( icon = "comment", color = "#ffffff", background_color = "#7c3aed", show = TRUE, marker_label = "Read room comments", popup_label = "Room comments", source_label = "Read source", size = 36, min_size = 12, fit_to_room = TRUE, placement = "edge" )indoorCommentOptions( icon = "comment", color = "#ffffff", background_color = "#7c3aed", show = TRUE, marker_label = "Read room comments", popup_label = "Room comments", source_label = "Read source", size = 36, min_size = 12, fit_to_room = TRUE, placement = "edge" )
icon |
One of |
color, background_color
|
Icon foreground and background colors as
hexadecimal |
show |
Whether to display comment icons. |
marker_label |
Accessible action label for a comment icon. The room label, when supplied, is appended automatically. |
popup_label |
Heading displayed above the room comments. |
source_label |
Label for each comment's source link. |
size |
Maximum visual badge diameter in CSS pixels. |
min_size |
Minimum visual badge diameter when fitting to a room. |
fit_to_room |
Scale the badge and its icon with the room's projected
size as the map zoom changes. Point features retain |
placement |
|
An object of class leaflet_indoor_comment_options.
indoorCommentOptions(icon = "quote", background_color = "#7c3aed") indoorCommentOptions(icon = "\u2605", marker_label = "Lire les témoignages", popup_label = "Témoignages", source_label = "Source")indoorCommentOptions(icon = "quote", background_color = "#7c3aed") indoorCommentOptions(icon = "\u2605", marker_label = "Lire les témoignages", popup_label = "Témoignages", source_label = "Source")
Options for an indoor floor control
indoorControlOptions( title = "Floor", descending = TRUE, max_height = 280, empty_label = "No levels" )indoorControlOptions( title = "Floor", descending = TRUE, max_height = 280, empty_label = "No levels" )
title |
Accessible title displayed above the floor buttons. |
descending |
Display higher floors above lower floors. |
max_height |
Maximum button-list height in CSS pixels. |
empty_label |
Text displayed when the linked data set has no floors. |
An object of class leaflet_indoor_control_options.
Create the style and interaction options used by addIndoor(). The three
geometry-specific lists use Leaflet path option names. Values supplied via
the style argument of addIndoor() override these defaults.
indoorOptions( point = NULL, line = NULL, polygon = NULL, pane = NULL, interactive = TRUE )indoorOptions( point = NULL, line = NULL, polygon = NULL, pane = NULL, interactive = TRUE )
point, line, polygon
|
Named lists of options for point, line, and polygon geometries. |
pane |
Optional Leaflet pane name. |
interactive |
Whether features receive mouse and keyboard events. |
An object of class leaflet_indoor_options.
Creates the tabular association used by addIndoor() to attach one or more
photos to indoor features. Each row associates a layerId with one image and
its caption. Repeating a layerId creates a carousel in row order.
indoorPhotoCatalog(layerId, src, caption, alt = caption)indoorPhotoCatalog(layerId, src, caption, alt = caption)
layerId |
Feature identifiers matching the values supplied to the
|
src |
Image sources. These may be HTTP(S) URLs, relative URLs, image data URIs, or paths to existing PNG, JPEG, GIF, WebP, or SVG files. |
caption |
Plain-text captions displayed immediately below their images. |
alt |
Plain-text alternative text. The default uses |
Existing local image files are embedded as data URIs so saved widgets, vignettes, Quarto documents, and Shiny applications do not depend on the original file path. Web URLs and relative URLs are retained unchanged.
A data frame of class leaflet_indoor_photos with columns
layerId, src, caption, and alt.
photos <- indoorPhotoCatalog( layerId = c("room-01", "room-01"), src = c( "https://example.org/room-01-a.jpg", "https://example.org/room-01-b.jpg" ), caption = c("Entrance view", "View from the windows") ) photosphotos <- indoorPhotoCatalog( layerId = c("room-01", "room-01"), src = c( "https://example.org/room-01-a.jpg", "https://example.org/room-01-b.jpg" ), caption = c("Entrance view", "View from the windows") ) photos
Controls the visible and accessible labels used by photo carousels created
when addIndoor() receives a non-empty photos catalogue. Labels can be
translated without changing the catalogue.
indoorPhotoOptions( previous_label = "Previous", next_label = "Next", enlarge_label = "Enlarge", close_label = "Close", carousel_label = "Room photos", dialog_label = "Enlarged room photo", counter_label = "Photo {current} of {total}", unavailable_label = "Image unavailable" )indoorPhotoOptions( previous_label = "Previous", next_label = "Next", enlarge_label = "Enlarge", close_label = "Close", carousel_label = "Room photos", dialog_label = "Enlarged room photo", counter_label = "Photo {current} of {total}", unavailable_label = "Image unavailable" )
previous_label |
Label for the previous-photo button. |
next_label |
Label for the next-photo button. |
enlarge_label |
Label for the button that opens the current photo and caption in a larger dialog. |
close_label |
Label for the dialog close button. |
carousel_label |
Accessible label for the carousel. |
dialog_label |
Accessible label for the enlarged-photo dialog. |
counter_label |
Counter template containing |
unavailable_label |
Text shown when an image cannot be loaded. |
An object of class leaflet_indoor_photo_options.
Remove an indoor floor control
removeIndoorControl(map, control_id = "indoor")removeIndoorControl(map, control_id = "indoor")
map |
A Leaflet map or proxy. |
control_id |
Control to remove. |
The input map or proxy.
Set the active indoor floor
setIndoorLevel(map, level, dataset_id = "indoor")setIndoorLevel(map, level, dataset_id = "indoor")
map |
A Leaflet map or proxy. |
level |
One non-missing floor value. |
dataset_id |
Indoor data set to update. |
The input map or proxy.