Select to view content in your preferred language

LayerDef/DefinitionExpression on ArcGISDynamicMapServiceLayer / Annotation Layer representation

955
2
06-30-2021 11:45 AM
JeffMachamer
Occasional Contributor

I am attempting to filter out data on the map (draw/export) inside a web application using the 3.x JS API but have discovered that I cannot seem to filter out data from a feature linked annotation layer.  The reason appears to be due to the fact that the display for the Annotation Layer is based on the "Default" sublayer/representation that is being used. (As seen in the rest end point for the map service showing up as Annotation Sublayer)  In a dynamic map service this shows up as a separate layer, but this separate layer does not contain any of the attributes to filter on.

I've attempted to set the filter on the sublayer despite the missing attributes using LayerDef property as well as definitionExpression in the dynamicLayers property, but without success. 

Is anyone aware of a way to somehow force the sublayer of an annotation layer to respect a definition expression applied to the parent layer?  I'm beginning to think this may just be something that doesn't work in the 3.x API / Dynamic Map Service.

Thanks in advance!

0 Kudos
2 Replies
Noah-Sager
Esri Regular Contributor

Hi @JeffMachamer, thanks for posting your question here. We have not seen this issue before. Do you have a link to a public MapServer with an Annotation Layer that I could do some testing with?

Edit update: I looked into this some more, and this seems like a limitation of working with an Annotation Layer when it is feature linked. However, I did notice that if the parent layer of the sublayer has a LayerDefinition, it seems to filter the visible features/labels. Here is an example of showing one feature:

https://codepen.io/noash/pen/YzVLeQm?editors=1000

More annotation layer information: 

https://pro.arcgis.com/en/pro-app/latest/help/data/annotation/annotation.htm

 

JeffMachamer
Occasional Contributor

Thanks for the feedback @Noah-Sager .  I unfortunately do not have a public service that I can share with this issue.

I'll have to dig back into this and validate the information provided, but I believe the problem we were seeing is that we were having to use the SubLayer in the export call to even make the annotation be drawn rather than the parent layer. Although it's possible we just use the sublayer instead of the parent layer because that's how we thought it was supposed to be done?

It the example you provided I noticed you had two sublayers defined.  I guess by using the parent layer you get all of the sublayers drawn.  In our case we only have a single sublayer defined "Default", so that isn't an issue for us, not sure if it would ever be an issue for others.

I thought I had tried changing the layer list to use the parent instead of the sub layer before posting this question, but a quick test via fiddler on our private service seems to suggest this should work for us.  

Thanks for the info, hopefully this will enable us to solve the problem.