addEsriDynamicMapLayer: Render and visualize Map Services from ArcGIS Online and...

Description Usage Arguments Examples

View source: R/dynamicMapLayers.R

Description

Map Services are a way to expose the contents of a map as a web service and expose capabilities for exporting tile images, querying and identifying features and more. Also supports custom popups and identification of features.

Usage

1
2
3
addEsriDynamicMapLayer(map, url, options = dynamicMapLayerOptions(),
  popupFunction = NULL, popupOptions = NULL, layerId = NULL,
  group = NULL)

Arguments

map

The leaflet map

url

URL of the Map Service.

options

options for the dynamic map layer.

popupFunction

Uses the provided function to create a popup that will identify features whenever the map is clicked. Your function will be passed a GeoJSON FeatureCollection of the features at the clicked location and should return the appropriate HTML. If you do not want to open the popup when there are no results, return false.

popupOptions

See popupOptions.

layerId

A unique ID for the layer.

group

The name of the group this layer should be added to.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
popupFunc <- htmlwidgets::JS(
  "function (error, featureCollection) {
    if (error || featureCollection.features.length === 0) {
      return false;
    } else {
    return \"Risk Level: \" + featureCollection.features[0].properties.CLASS_DESC;
    }
  }")

leaflet() %>% setView(-96.8, 38.5, 4) %>%
  addEsriBasemapLayer(esriBasemapLayers$Gray, autoLabels = TRUE) %>%
  addEsriDynamicMapLayer(
    url = paste0("https://maps7.arcgisonline.com/arcgis/rest/services/",
                 "USDA_USFS_2014_Wildfire_Hazard_Potential/MapServer"),
    popupFunction = popupFunc)

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

bhaskarvk/leaflet.esri documentation built on Oct. 3, 2021, 5:47 a.m.