Select to view content in your preferred language

Copying a layer from one map to another.

607
1
06-21-2010 06:01 AM
jonataspovoas
Regular Contributor
I am doing a project in Silverlight and I need to copy a GraphicsLayer from a Map to another (the main application Map and a ChildWindow print Map). How can i do this?

I tried this but it doen't work.

PrintingMap.Layers.Add(Map.Layers["MyGraphicsLayer"]);
0 Kudos
1 Reply
MikeKaufman
Emerging Contributor
From what I noticed, the graphics in a layer is much like a datarow in a datatable.  A datarow can only belong to one datatable.  Seems like the same applies with a layer and the graphics that belong to it.  Here is what I did to copy a layer to another.
Dim gLayer As New GraphicsLayer
gLayer.ID = "Test"
        For Each graphic In _selectLayer
            Dim g As New Graphic
            g.Geometry = graphic.Geometry
            g.Symbol = graphic.Symbol
            gLayer.Graphics.Add(g)
        Next
        
0 Kudos