I am trying to use Openlayers ImageArcGisRest to add layers on a openlayers map from ArcGis Map Server. I have to pass a token in to the function as the application uses token authentication.
I've found that the map loads fine if I log into the map server first. It also returns the data when I use Postman with the token, so I know the token is fine. It seems to break when I try to give it a token, I think it is to do with my syntax. I have other layers to that work fine so I know its not the setting up of the map code later on.
var token = _my_token;
var url =`http://myserver.com/webadaptor/rest/services/MyMapName/MapServer?token=`+token;
this.baselayers =
new ImageLayer({
source: new ImageArcGISRest({
ratio: 1,
params: {
LAYERS: this.visibleMapIds //("show:1,2,3")
},
url: url
})
});
I have also tried:
var token = my_token;
var url =`http://myserver.com/webadaptor/rest/services/MyMapName/MapServer/`;
this.baselayers =
new ImageLayer({
source: new ImageArcGISRest({
ratio: 1,
params: {
token: my_token,
LAYERS: this.visibleMapIds //("show:1,2,3")
},
url: url
})
});
I received this error when I try to run either option: "Assertion failed. See https://openlayers.org/en/v5.3.0/doc/errors/#50 for details."
I really just need to know how you pass the token but ArcGis's documentation isn't the most helpful.
It was just a syntax error. The below code works fine:
var token = my_token;
var url =`http://myserver.com/webadaptor/rest/services/MyMapName/MapServer/`;
this.baselayers =
new ImageLayer({
source: new ImageArcGISRest({
ratio: 1,
params: {
TOKEN: my_token,
LAYERS: this.visibleMapIds //("show:1,2,3")
},
url: url
})
});