I am trying to user the leaflet.esri library in R and I cannot find a way to add a layer from my Portal or ArcGIS Server.
The sample code I am using in the following and you can find it here: https://cran.r-project.org/web/packages/leaflet.esri/leaflet.esri.pdf
library(leaflet.esri)
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://myArcGISServer.com/arcgis/rest/services/MapServices/MyLayer/MapServer/7"),
popupFunction = popupFunc)