Select to view content in your preferred language

How to save a custom layer in ArcMap to mxd?

639
1
Jump to solution
07-06-2017 02:32 AM
deleted-user-OFT1wBX1CgU4
Deactivated User

Hello,

to be clear from the beginning: I'm not loooking for saving a custom layer to a layer file (for that I found many examples), but I want to get my custom layers saved to the mxd-files so that this layers would be displayed if the user reopens the file.

I'm using as underlying library ArcBrutile and I'm displaying HERE-Maps. I found this (old) article about layers and nearly the same article for a current ArcGIS version for Java. The first one states that I need for saving to implement the "IPersistStream"-Interface, while the other one tells me that I need "IPersistVariant"-Interface. Originally the "IPersistVariant"-interface already was implemented for the layers. I tried to implement also the "IPersistStream"-Interface, but the layers still won't be saved to the mxd-file.

So how I'm able to save tiled custom layers to mxd?

0 Kudos
1 Solution

Accepted Solutions
deleted-user-OFT1wBX1CgU4
Deactivated User

After a while I noticed that the mxd doctor is showing the right guid for my layer saved in the mxd files, but he couldn't resolve which type this guid belongs to. The solution is to ensure that the class will be com registered via esriregasm (which in my case already happened with that project) and that the needed classes have a an explicitly defined default constructor which can be used by the registration process.

So my class only had "specialized" constructors with parameters, but no explicitly defined default constructor without parameters. After adding this everything worked. ArcMap can now resolve which type the saved guid belongs to and rebuild the layer (in it's save/load method one has to ensure that all needed information are persisted and the building up happens in the right way).

View solution in original post

0 Kudos
1 Reply
deleted-user-OFT1wBX1CgU4
Deactivated User

After a while I noticed that the mxd doctor is showing the right guid for my layer saved in the mxd files, but he couldn't resolve which type this guid belongs to. The solution is to ensure that the class will be com registered via esriregasm (which in my case already happened with that project) and that the needed classes have a an explicitly defined default constructor which can be used by the registration process.

So my class only had "specialized" constructors with parameters, but no explicitly defined default constructor without parameters. After adding this everything worked. ArcMap can now resolve which type the saved guid belongs to and rebuild the layer (in it's save/load method one has to ensure that all needed information are persisted and the building up happens in the right way).

0 Kudos