Learn R Programming

simplevis (version 1.1.4)

leaflet_sf: Map of simple features in leaflet.

Description

Map of simple features in leaflet that is not coloured.

Usage

leaflet_sf(data, pal = NULL,
  popup = leafpop::popupTable(sentence_spaced_colnames(data)),
  radius = 1, weight = 2, opacity = 0.1, stroke = TRUE,
  title = "[Title]", legend_digits = 1, legend_labels = "[Feature]",
  shiny = FALSE, basemap = "light", map_id = "map")

Arguments

data

An sf object of geometry type point/multipoint, linestring/multilinestring or polygon/multipolygon geometry type. Required input.

pal

Character vector of hex codes. Defaults to NULL, which selects the Stats NZ palette.

popup

HTML strings for use in popup. Defaults to making a leafpop::popupTable of all attribute columns in the sf object.

radius

Radius of points. Defaults to 1.

weight

Stroke border size. Defaults to 2.

opacity

The opacity of the fill. Defaults to 0.1. Only applicable to polygons.

stroke

TRUE or FALSE of whether to draw a border around the features. Defaults to T.

title

A title string that will be wrapped into the legend. Defaults to "Title"

legend_digits

Select the appropriate number of decimal places for numeric variable auto legend labels. Defaults to 1.

legend_labels

A vector of legend label values. Defaults to "Feature".

shiny

TRUE or FALSE for whether the map is being run within a shiny app. Defaults to FALSE.

basemap

The underlying basemap. Either "light", "dark", "satellite", "street", or "ocean". Defaults to "light". Only applicable where shiny equals FALSE.

map_id

The shiny map id for a leaflet map within a shiny app. For standard single-map apps, id "map" should be used. For dual-map apps, "map1" and "map2" should be used. Defaults to "map".

Value

A leaflet object.

Examples

Run this code
# NOT RUN {
map_data <- example_sf_nz_river_wq %>%
  dplyr::filter(period == "1998-2017", indicator == "Nitrate-nitrogen")

leaflet_sf(map_data)
# }

Run the code above in your browser using DataLab