<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How do I copy A layer service from one map to another? in ArcGIS API for Silverlight Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-do-i-copy-a-layer-service-from-one-map-to/m-p/757764#M19364</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have two pages on my project (main and print pages), and both has the same map with the same layers&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have this Layers on my maps:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;esri:Map x:Name="MapaImpressao" Background="#FFC3D2E5" IsLogoVisible="False" Extent = "-183.780014728684,-124.638910568344,179.99999,124.638910568344" Margin="-1,7,-1,-14"&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;[INDENT][INDENT]&amp;lt;esri:ArcGISTiledMapServiceLayer ID="Streets World 2D" Url="&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" rel="nofollow" target="_blank"&gt;http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer&lt;/A&gt;&lt;SPAN&gt;"/&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;esri:ArcGISDynamicMapServiceLayer ID="StateCityHighway USA"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;Url="&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer" rel="nofollow" target="_blank"&gt;http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer&lt;/A&gt;&lt;SPAN&gt;"/&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;esri:GraphicsLayer ID="MyGraphicsLayer" /&amp;gt;[/INDENT][/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/esri:Map&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;here's my problem: During execution I have to copy the Layers Alteration from one to another. I already copy the Graphics from one GraphicLayer to another, but the Layers from the&amp;nbsp; services that the user Disabled/Enabled are giving me a headache. Does anyone knows how to copy them to another map?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;when i disable a service, i can copy the change, but when disabling a Layer I can't copy it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This copy the change at the service&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;foreach (Layer ChosenLayer in this.Mapa.Layers)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT][INDENT]if (!ChosenLayer.Visible) imprimir.MapaImpressao.Layers[ChosenLayer.ID].Visible = false;[/INDENT][/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;With this i copy my graphycsLayer:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;GraphicsLayer Origem = Mapa.Layers["MyGraphicsLayer"] as GraphicsLayer;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;GraphicsLayer Destino = imprimir.MapaImpressao.Layers["MyGraphicsLayer"] as GraphicsLayer;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;foreach (Graphic i in Origem)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT][INDENT]Graphic g = new Graphic();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;g.Geometry = i.Geometry;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;g.Symbol = i.Symbol;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Destino.Graphics.Add(g);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[/INDENT][/INDENT]}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's a screen shot of the Layers listing box:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;A href="&amp;lt;/span&amp;gt;&amp;lt;a" target="_blank"&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;IMG src="http://img682.imageshack.us/img682/9959/imagemhqv.th.jpg" /&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 28 Jun 2010 14:05:48 GMT</pubDate>
    <dc:creator>jonataspovoas</dc:creator>
    <dc:date>2010-06-28T14:05:48Z</dc:date>
    <item>
      <title>How do I copy A layer service from one map to another?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-do-i-copy-a-layer-service-from-one-map-to/m-p/757764#M19364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have two pages on my project (main and print pages), and both has the same map with the same layers&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have this Layers on my maps:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;esri:Map x:Name="MapaImpressao" Background="#FFC3D2E5" IsLogoVisible="False" Extent = "-183.780014728684,-124.638910568344,179.99999,124.638910568344" Margin="-1,7,-1,-14"&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;[INDENT][INDENT]&amp;lt;esri:ArcGISTiledMapServiceLayer ID="Streets World 2D" Url="&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" rel="nofollow" target="_blank"&gt;http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer&lt;/A&gt;&lt;SPAN&gt;"/&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;esri:ArcGISDynamicMapServiceLayer ID="StateCityHighway USA"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;Url="&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer" rel="nofollow" target="_blank"&gt;http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer&lt;/A&gt;&lt;SPAN&gt;"/&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;esri:GraphicsLayer ID="MyGraphicsLayer" /&amp;gt;[/INDENT][/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/esri:Map&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;here's my problem: During execution I have to copy the Layers Alteration from one to another. I already copy the Graphics from one GraphicLayer to another, but the Layers from the&amp;nbsp; services that the user Disabled/Enabled are giving me a headache. Does anyone knows how to copy them to another map?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;when i disable a service, i can copy the change, but when disabling a Layer I can't copy it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This copy the change at the service&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;foreach (Layer ChosenLayer in this.Mapa.Layers)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT][INDENT]if (!ChosenLayer.Visible) imprimir.MapaImpressao.Layers[ChosenLayer.ID].Visible = false;[/INDENT][/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;With this i copy my graphycsLayer:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;GraphicsLayer Origem = Mapa.Layers["MyGraphicsLayer"] as GraphicsLayer;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;GraphicsLayer Destino = imprimir.MapaImpressao.Layers["MyGraphicsLayer"] as GraphicsLayer;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;foreach (Graphic i in Origem)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT][INDENT]Graphic g = new Graphic();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;g.Geometry = i.Geometry;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;g.Symbol = i.Symbol;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Destino.Graphics.Add(g);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[/INDENT][/INDENT]}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's a screen shot of the Layers listing box:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;A href="&amp;lt;/span&amp;gt;&amp;lt;a" target="_blank"&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;IMG src="http://img682.imageshack.us/img682/9959/imagemhqv.th.jpg" /&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Jun 2010 14:05:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-do-i-copy-a-layer-service-from-one-map-to/m-p/757764#M19364</guid>
      <dc:creator>jonataspovoas</dc:creator>
      <dc:date>2010-06-28T14:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I copy A layer service from one map to another?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-do-i-copy-a-layer-service-from-one-map-to/m-p/757765#M19365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I tried following code to copy the Layers (altered from the default visibility) from one map to another and it works fine for me. Basically at the click of copy button I fetched the visible layers of the target ArcGISDynamicMapServiceLayer, created a new ArcGISDynamicMapServiceLayer in destination Map and gave same URL as Source map and set visiblity of layers and add the layer to destination Map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; private void copy_Click(object sender, RoutedEventArgs e)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ArcGISDynamicMapServiceLayer destinationLayer = new ArcGISDynamicMapServiceLayer();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ArcGISDynamicMapServiceLayer OriginLayer = MyMap.Layers["MyDynamicLayer"] as ArcGISDynamicMapServiceLayer;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;//give the URL as the source map's DynamicService Layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; destinationLayer.Url=OriginLayer.Url;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;//get all the visible layers from source service&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;int&amp;gt; visibleLayerList =&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OriginLayer.VisibleLayers != null&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ? OriginLayer.VisibleLayers.ToList() : new List&amp;lt;int&amp;gt;();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;//set the visiblelayers to what we got from above&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; destinationLayer.VisibleLayers=visibleLayerList.ToArray();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;//add to destination Map&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TargetMap.Layers.Add(destinationLayer);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Jun 2010 21:02:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-do-i-copy-a-layer-service-from-one-map-to/m-p/757765#M19365</guid>
      <dc:creator>PreetiMaske</dc:creator>
      <dc:date>2010-06-28T21:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: How do I copy A layer service from one map to another?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-do-i-copy-a-layer-service-from-one-map-to/m-p/757766#M19366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've found some small bugs in the code u sugested: If it happens to try copying the service without any change in it's layers, it behaves as if the service was unshown, but the default visibility is enabled! Also, if i deactivate an service, and have a Layer unchecked on the list (in other words, also deactivated) it keeps showing the two activated layers of that service.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One more thing, could you explain to me how this lines works? When my boss asked me, i couldn't explain well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;List&amp;lt;int&amp;gt; visibleLayerList = OriginLayer.VisibleLayers != null ? OriginLayer.VisibleLayers.ToList() : new List&amp;lt;int&amp;gt;();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks a lot!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jun 2010 10:31:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-do-i-copy-a-layer-service-from-one-map-to/m-p/757766#M19366</guid>
      <dc:creator>jonataspovoas</dc:creator>
      <dc:date>2010-06-30T10:31:37Z</dc:date>
    </item>
  </channel>
</rss>

