Problem consuming Annotation Layer: "invalid response"

451
3
10-09-2019 12:29 PM
PhilScovis
New Contributor III

I'm trying to learn how to consume an "Annotation Layer" from the UWP Runtime.  My first thought was to use the AnnotationLayer object in the same way that I had used "FeatureLayer" before.  

Uri uri = new Uri(_AnnotationUri.ToString() + "/" + _AnnotationLayerId.ToString());
_AnnotationLayer = new AnnotationLayer(uri);
_AnnotationLayer.IsVisible = true;
_MapView.Map.OperationalLayers.Add(_AnnotationLayer);

await _AnnotationLayer.LoadAsync();

However, this gives an error "invalid response" on the last line, with no further information.  Am I doing this correctly?

I watched the traffic in Fiddler, and it seems that it is dropping off the layer id in the request uri.  The response looks like a description of all the layers on the service, not just the one I was after.  This would account for the "invalid response".  But what is the correct way to load and display an Annotation Layer then?  

Thanks for any help.

0 Kudos
3 Replies
MichaelBranscomb
Esri Frequent Contributor

Hi,

Can you share an example of the URI string you're providing?

Cheers

Mike

0 Kudos
PhilScovis
New Contributor III

Sure.  This is not public, but you can see what it looks like:

https://usalvwdgis1.infor.com:6443/arcgis/rest/services/WALTERS/Sacramento_AnnoTest/MapServer 

My code is adding on a /0 to the end. 

https://usalvwdgis1.infor.com:6443/arcgis/rest/services/WALTERS/Sacramento_AnnoTest/MapServer/0 

But as I said, the layer id is being stripped off in the actual request.

The response to the runtime looks like this:

{"currentVersion":10.51,"serviceDescription":"","mapName":"Layers","description":"","copyrightText":"","supportsDynamicLayers":true,"layers":[{"id":0,"name":"ParcelsAnno2","parentLayerId":-1,"defaultVisibility":true,"subLayerIds":[1,2,3],"minScale":20000,"maxScale":0}, ... and so on.

which, of course, is not going to the specific layer I wanted.

Going through a browser, and including the layer id, I would get this:

{"currentVersion":10.51,"id":0,"name":"ParcelsAnno2","type":"Annotation Layer","description":"","geometryType":"esriGeometryPolygon","sourceSpatialReference":{"wkid":102642,"latestWkid":2226},"copyrightText":"","parentLayer":null,"subLayers":[{"id":1,"name":"Default"},{"id":2,"name":"GT37065"}, ...

So the problem seems to be in how I am initializing or using the AnnotationLayer object.

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

Hi,

Annotation is currently only supported from the `.../FeatureServer/... endpoint so your code just needs to be updated to:

`https://usalvwdgis1.infor.com:6443/arcgis/rest/services/WALTERS/Sacramento_AnnoTest/FeatureServer/0`

Cheers

Mike