addEsriFeatureLayer: Adds an ArcGIS Feature Layer.

Description Usage Arguments Examples

View source: R/featureLayers.R

Description

FeatureLayer is used to visualize, style, query and edit vector geographic data hosted in both ArcGIS Online and published using ArcGIS Server. Copyright text from the service is added to map attribution automatically.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
addEsriFeatureLayer(map, url, useServiceSymbology = FALSE,
  options = featureLayerOptions(), layerId = NULL, group = NULL,
  markerType = NULL, markerIcons = NULL, markerIconProperty = NULL,
  markerOptions = leaflet::markerOptions(), clusterOptions = NULL,
  clusterId = NULL, labelProperty = NULL,
  labelOptions = leaflet::labelOptions(), popupProperty = NULL,
  popupOptions = leaflet::popupOptions(), stroke = TRUE, color = "#03F",
  weight = 5, opacity = 0.5, fill = TRUE, fillColor = color,
  fillOpacity = 0.2, dashArray = NULL, smoothFactor = 1, noClip = FALSE,
  pathOptions = leaflet::pathOptions(), highlightOptions = NULL,
  fitBounds = FALSE)

Arguments

map

The leaflet map

url

url of the FeatureService or MapService.

useServiceSymbology

whether to use the symbology set when a service was published.

options

options for the featurelayer

layerId

A unique ID for the layer.

group

The name of the group this layer should be added to. the same parameter under addTiles)

markerType

The type of marker. either "marker" or "circleMarker"

markerIcons

Icons for Marker.

markerIconProperty

The property of the feature to use for marker icon. Can be a JS function which accepts a feature and returns an index of markerIcons. In either case the result must be one of the indexes of markerIcons.

markerOptions

The options for markers Can be a single marker using makeIcon or a list of markers using iconList

clusterOptions

if not NULL, markers will be clustered using Leaflet.markercluster; you can use markerClusterOptions() to specify marker cluster options

clusterId

the id for the marker cluster layer

labelProperty

The property to use for the label. You can also pass in a JS function that takes in a feature and returns a text/HTML content.

labelOptions

A Vector of labelOptions to provide label options for each label. Default NULL

popupProperty

The property to use for popup content You can also pass in a JS function that takes in a feature and returns a text/HTML content.

popupOptions

A Vector of popupOptions to provide popups

stroke

whether to draw stroke along the path (e.g. the borders of polygons or circles)

color

stroke color

weight

stroke width in pixels

opacity

stroke opacity (or layer opacity for tile layers)

fill

whether to fill the path with color (e.g. filling on polygons or circles)

fillColor

fill color

fillOpacity

fill opacity

dashArray

a string that defines the stroke dash pattern

smoothFactor

how much to simplify the polyline on each zoom level (more means better performance and less accurate representation)

noClip

whether to disable polyline clipping

pathOptions

Options for shapes

highlightOptions

Options for highlighting the shape on mouse over. you can use highlightOptions() to specify highlight

fitBounds

Whether to set the maps bounds to fit the data in the featureLayer options

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
leaflet() %>%
  addEsriBasemapLayer(esriBasemapLayers$Streets) %>%
  setView(-122.667, 45.526, 13) %>%
  addEsriFeatureLayer(
    url = paste0("https://services.arcgis.com/rOo16HdIMeOBI4Mb/arcgis/rest/services/",
                 "Heritage_Trees_Portland/FeatureServer/0"),
    useServiceSymbology = TRUE,
    labelProperty = "COMMON_NAM", labelOptions = labelOptions(textsize = "12px"),
  popupProperty = JS(paste0(
    "function(feature) {",
    "  return L.Util.template(",
    "    \"<h3>{COMMON_NAM}</h3><hr />",
    "      <p>This tree is located at {ADDRESS} and its scientific name is {SCIENTIFIC}.</p>",
    "    \",",
    "    feature.properties",
    "  );",
    "}"
  )))

## for more examples see
# browseURL(system.file("examples/featureLayers.R", package = "leaflet.esri"))
# browseURL(system.file("examples/multipleFeatureLayers.R", package = "leaflet.esri"))

Example output

Loading required package: leaflet
Loading required package: leaflet.extras

leaflet.esri documentation built on May 2, 2019, 2:39 a.m.