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)
Giacomo,
Thank you for the report. The leaflet.esri package isn't something we wrote in house, it lives here on Github:
GitHub - bhaskarvk/leaflet.esri: ESRI Plugin for Leaflet R Package
You may be able to adapt the Esri Leaflet basic examples for authentication, for example following this example: ArcGIS Server username/password | Esri Leaflet
We're also examining what handling authenticated services via the R-ArcGIS bridge package might look like for a future release.
Cheers,
Shaun