-
Notifications
You must be signed in to change notification settings - Fork 85
Access Secured ArcGIS Layers in your App using Runtime
Sathya Prasad edited this page Apr 28, 2016
·
3 revisions
If you would like to add a secured ArcGIS layer (Feature Service or Map Service or Image Service) originating from your own ArcGIS Servers / on-premise portal / hosted ArcGIS Online servers then you would need to authorize your REST calls with appropriate user credentials.
- Create a UserCredentials object
//You could harcode the credentials in code, read it from properties file or ask user
UserCredentials {
id: userCredentials
userName: "user1"
password: "pass.word1"
}
- Use this credentials object inside of your Runtime object
//service info call
ServiceInfoTask {
id: serviceInfoTask
url: "http://serverapps10.esri.com/ArcGIS/rest/services/MontgomeryEdit/FeatureServer"
credentials: userCredentials
}
//Feature service using ArcGISFeature Layer
ArcGISFeatureLayer {
id: featLayerPremisePoints
url: "http://serverapps10.esri.com/ArcGIS/rest/services/MontgomeryEdit/FeatureServer/0"
credentials: userCredentials
}
//Feature service using FeatureLayer + GeodatabaseFeatureServiceTable
FeatureLayer {
id: featLayer
visible: true
featureTable: featTable.valid? featTable : null
credentials: userCredentials
}
GeodatabaseFeatureServiceTable {
id: featTable
url: "http://serverapps10.esri.com/ArcGIS/rest/services/MontgomeryEdit/FeatureServer/0"
credentials: userCredentials
//credentials: UserCredentials { username: “abcdef”; password:”12345678”}
}
//ArcGIS Dynamic Service (Map Service) layer
ArcGISDynamicMapServiceLayer {
id: layer1
url: "http://serverapps10.esri.com/ArcGIS/rest/services/MontgomeryEdit/MapServer"
credentials: userCreds
onStatusChanged: {
console.log(status, statusString)
if(status === Enums.LayerStatusInitialized) {
map.zoomTo(layer1.fullExtent.project(map.spatialReference))
}
}
}