This function produces an interactive view of the extent/bbox of the supplied spatial object
Usage
viewExtent(
x,
map = NULL,
popup = NULL,
layer.name = NULL,
alpha.regions = 0.2,
label = NULL,
...
)Arguments
- x
either a Raster*, sf* or Spatial* object
- map
a leaflet or mapview map the extent should be added to. If NULL standard background layers are created.
- popup
a
listof HTML strings with the popup contents, usually created frompopupTable. SeeaddControlfor details.- layer.name
the name of the layer to be shown on the map.
- alpha.regions
opacity of the fills or the raster layer(s).
- label
a character vector of labels to be shown on mouseover. See
addControlfor details.- ...
Arguments passed on to
leaflet::addRectangleshtmlthe content of the control. May be provided as string or as HTML generated with Shiny/htmltools tags
positionposition of control:
"topleft","topright","bottomleft", or"bottomright".layerIdthe layer id
classNameextra CSS classes to append to the control, space separated
datathe data object from which the argument values are derived; by default, it is the
dataobject provided toleaflet()initially, but can be overriddenurlTemplatea character string as the URL template
attributionthe attribution text of the tile layer (HTML)
groupthe name of the group the newly created layers should belong to (for
clearGroup()andaddLayersControl()purposes). Human-friendly group names are permitted–they need not be short, identifier-style names. Any number of layers and even different types of layers (e.g., markers and polygons) can share the same group name.optionsa list of extra options for tile layers, popups, paths (circles, rectangles, polygons, ...), or other map elements
baseUrla base URL of the WMS service
layerscomma-separated list of WMS layers to show
lnga numeric vector of longitudes, or a one-sided formula of the form
~xwherexis a variable indata; by default (if not explicitly provided), it will be automatically inferred fromdataby looking for a column namedlng,long, orlongitude(case-insensitively)lata vector of latitudes or a formula (similar to the
lngargument; the nameslatandlatitudeare used when guessing the latitude column fromdata)iconthe icon(s) for markers; an icon is represented by an R list of the form
list(iconUrl = "?", iconSize = c(x, y)), and you can useicons()to create multiple icons; note when you use an R list that contains images as local files, these local image files will be base64 encoded into the HTML page so the icon images will still be available even when you publish the map elsewherepopupOptionsA Vector of
popupOptions()to provide popupslabelOptionsA Vector of
labelOptions()to provide label options for each label. DefaultNULLclusterOptionsif not
NULL, markers will be clustered using Leaflet.markercluster; you can usemarkerClusterOptions()to specify marker cluster optionsclusterIdthe id for the marker cluster layer
radiusa numeric vector of radii for the circles; it can also be a one-sided formula, in which case the radius values are derived from the
data(units in meters for circles, and pixels for circle markers)strokewhether to draw stroke along the path (e.g., the borders of polygons or circles)
colorstroke color
weightstroke width in pixels
opacitystroke opacity (or layer opacity for tile layers)
fillwhether to fill the path with color (e.g., filling on polygons or circles)
fillColorfill color
fillOpacityfill opacity
dashArraya string that defines the stroke dash pattern
bringToFrontWhether the shape should be brought to front on hover.
sendToBackwhether the shape should be sent to back on mouse out.
highlightOptionsOptions for highlighting the shape on mouse over.
smoothFactorhow much to simplify the polyline on each zoom level (more means better performance and less accurate representation)
noClipwhether to disable polyline clipping
lng1,lat1,lng2,lat2latitudes and longitudes of the south-west and north-east corners of rectangles
geojsona GeoJSON list, or character vector of length 1
topojsona TopoJSON list, or character vector of length 1
Examples
library(leaflet)
viewExtent(breweries)
viewExtent(franconia) + breweries
mapview(franconia) %>% leafem::addExtent(franconia, fillColor = "yellow")
leaflet() %>% addProviderTiles("OpenStreetMap") %>% leafem::addExtent(breweries)
leaflet() %>% addProviderTiles("OpenStreetMap") %>% leafem::addExtent(breweries)