Problem adding a layer twice

Discussion created by arxit20 on Nov 21, 2011
Hi all,

I'm creating a map in ArcObject 10, .Net from a SOE in order to export it in different formats.
The problem is:

I want to add a layer twice (with different renderers) and the second time I add it, it removes the first one (or it replaces the renderer I don't know).

Do you have any idea of how I could do this?

Here is a sample of my code:

//Gets the layer from the mapservice where the SOE is published
IMapServer3 mapServer = this.serverObjectHelper.ServerObject as IMapServer3;
IMapServerObjects mapObj = (IMapServerObjects)mapServer;
IMap map = mapObj.get_Map(mapServer.DefaultMapName);
IGeoFeatureLayer featureLayer = map.get_Layer(myLayerId) as IGeoFeatureLayer;
featureLayer.Renderer = Renderer1;

IGeoFeatureLayer featureLayer2 = map.get_Layer(myLayerId) as IGeoFeatureLayer;
featureLayer2.Renderer = Renderer2;

//Adds the layer to the newly created map

This code works correctly if the 2 layers retrieved don't have the same id in the instruction map.get_Layer(). Otherwise, only the second is displayed.

Any Idea?
Thanks in advance.