Select to view content in your preferred language

Making a custom layer serializable

1135
4
12-13-2012 04:32 AM
JohanCarlsson
Regular Contributor
Hi!

I've created my own layer type but it's not compatible with the PrintTool. I'm guessing this is because it's not serializable, but the error message in the tool doesn't give much help. My layer type inherits from GraphicsLayer. I've found this information about what the print task needs to perform a print of a layer:

http://resources.arcgis.com/en/help/main/10.1/index.html#/ExportWebMap_specification/0154000004w8000...

My question is, how do I make my layer serializable? Isn't it enough that it inherits from GraphicsLayer? Is there an example on how to achieve this available somewhere? I've reverse enginereed the JSON under "Syntax for client side graphics" to .NET classes for C# but I don't know how to use them and where. The information I need printed from my custom layer class are just graphics (i.e. geometry, symbols, extent). Is there any way to simply use the functionality from the GraphicsLayer class to achieve what I want? The functionality provided by my layer class is not needed when printing. I've tried casting my layer type as a GraphicsLayer instead to the print task but I can't get it to work.

Right now I've solved the problem by simply cloning all graphics from my layer type to a temporary GraphicsLayer, hiding my incompatible layer, and then deleting the temporary layer when the print is finished, but I want something a bit more compatible for the future.

Regards
Johan
0 Kudos
4 Replies
DominiqueBroux
Esri Frequent Contributor
You are right, custom layers inheriting from GraphicsLayer can't be printed.

We'll try enhancing it in a future version.

Thanks for reporting that.
0 Kudos
JohanCarlsson
Regular Contributor
You are right, custom layers inheriting from GraphicsLayer can't be printed.

We'll try enhancing it in a future version.

Thanks for reporting that.


So there is no way for me to work around this using the information provided in the ExportWebMap specification?
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Unfortunately I don't figure out any workaround except rewriting by yourself the webmap serialization but it's not that easy.

Maybe, instead of subclassing the GraphicsLayer, you might add the new functionalities you need by using attached properties.
But it's just my 2cts because I have idea about your need.
0 Kudos
JohanCarlsson
Regular Contributor
Unfortunately I don't figure out any workaround except rewriting by yourself the webmap serialization but it's not that easy.

Maybe, instead of subclassing the GraphicsLayer, you might add the new functionalities you need by using attached properties.
But it's just my 2cts because I have idea about your need.


Rewriting the webmap serialization is what I'd like to do, but it's above my level. I'll see if this is solvable with attached properties instead. Thanks!
0 Kudos