<?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 Re: Adding multiple layers in specific ORDER. in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/adding-multiple-layers-in-specific-order/m-p/422283#M5092</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Based on your code, each layer will be added when the OpenAsync call returns. If you want to added them in a specific order you either need to await each call to load_feature_layer_extras, or consider managing the index positions at which you want to insert the layers. The default behavior of ArcGIS is usually to insert layers in this order:&lt;/P&gt;&lt;P&gt;- Points&lt;/P&gt;&lt;P&gt;- Lines&lt;/P&gt;&lt;P&gt;- Polygons&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Therefore you might even consider implementing similar behavior, depending on the context of your app.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 May 2015 12:28:52 GMT</pubDate>
    <dc:creator>MichaelBranscomb</dc:creator>
    <dc:date>2015-05-28T12:28:52Z</dc:date>
    <item>
      <title>Adding multiple layers in specific ORDER.</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/adding-multiple-layers-in-specific-order/m-p/422282#M5091</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am adding 1 basemap and 6 feature layers to a map.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is that the "&lt;SPAN style="color: #2873ee;"&gt;OpenAsync&lt;/SPAN&gt;" call is causing the map to add the layers with a different order that i initially called them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please take a look at the following code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;SPAN style="color: blue;"&gt;void&lt;/SPAN&gt; _mapView_LayerLoaded(&lt;SPAN style="color: blue;"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="color: #2b91af;"&gt;LayerLoadedEventArgs&lt;/SPAN&gt; e)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: blue;"&gt;if&lt;/SPAN&gt; (e.Layer.ID == &lt;SPAN style="color: #a31515;"&gt;"basemap"&lt;/SPAN&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; loadOtherLayers();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: blue;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: blue;"&gt;void&lt;/SPAN&gt; loadOtherLayers()&lt;/P&gt;&lt;P&gt;{&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; load_feature_layer_extras((&lt;SPAN style="color: blue;"&gt;int&lt;/SPAN&gt;)&lt;SPAN style="color: #2b91af;"&gt;LayerIdEnum_Extra&lt;/SPAN&gt;.LayerAreas, &lt;SPAN style="color: #a31515;"&gt;"AREA"&lt;/SPAN&gt;);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; load_feature_layer_extras((&lt;SPAN style="color: blue;"&gt;int&lt;/SPAN&gt;)&lt;SPAN style="color: #2b91af;"&gt;LayerIdEnum_Extra&lt;/SPAN&gt;.LayerBlocks, &lt;SPAN style="color: #a31515;"&gt;"BLOCKS"&lt;/SPAN&gt;);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; load_feature_layer_extras((&lt;SPAN style="color: blue;"&gt;int&lt;/SPAN&gt;)&lt;SPAN style="color: #2b91af;"&gt;LayerIdEnum_Extra&lt;/SPAN&gt;.LayerRoads, &lt;SPAN style="color: #a31515;"&gt;"ROAD NETWORK"&lt;/SPAN&gt;);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; load_feature_layer_extras((&lt;SPAN style="color: blue;"&gt;int&lt;/SPAN&gt;)&lt;SPAN style="color: #2b91af;"&gt;LayerIdEnum&lt;/SPAN&gt;.LayerLinks, &lt;SPAN style="color: #a31515;"&gt;"LINKS"&lt;/SPAN&gt;);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; load_feature_layer_extras((&lt;SPAN style="color: blue;"&gt;int&lt;/SPAN&gt;)&lt;SPAN style="color: #2b91af;"&gt;LayerIdEnum&lt;/SPAN&gt;.LayerContainers, &lt;SPAN style="color: #a31515;"&gt;"CONTAINERS"&lt;/SPAN&gt;);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; load_feature_layer_extras((&lt;SPAN style="color: blue;"&gt;int&lt;/SPAN&gt;)&lt;SPAN style="color: #2b91af;"&gt;LayerIdEnum&lt;/SPAN&gt;.LayerNodes, &lt;SPAN style="color: #a31515;"&gt;"NODES"&lt;/SPAN&gt;);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: blue;"&gt;private&lt;/SPAN&gt; &lt;SPAN style="color: blue;"&gt;async&lt;/SPAN&gt; &lt;SPAN style="color: blue;"&gt;void&lt;/SPAN&gt; load_feature_layer_extras(&lt;SPAN style="color: blue;"&gt;int&lt;/SPAN&gt; layerId, &lt;SPAN style="color: blue;"&gt;string&lt;/SPAN&gt; layerName)&lt;/P&gt;&lt;P&gt;{ &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: blue;"&gt;var&lt;/SPAN&gt; featureLayer = &lt;SPAN style="color: blue;"&gt;await&lt;/SPAN&gt; Esri.ArcGISRuntime.Data.&lt;SPAN style="color: #2b91af;"&gt;ServiceFeatureTable&lt;/SPAN&gt;.OpenAsync(&lt;SPAN style="color: blue;"&gt;new&lt;/SPAN&gt; &lt;SPAN style="color: #2b91af;"&gt;Uri&lt;/SPAN&gt;(unetworkServiceURL_Extra + &lt;SPAN style="color: blue;"&gt;string&lt;/SPAN&gt;.Format(&lt;SPAN style="color: #a31515;"&gt;"FeatureServer/{0}"&lt;/SPAN&gt;, layerId)));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; featureLayer.Mode = &lt;SPAN style="color: #2b91af;"&gt;QueryMode&lt;/SPAN&gt;.OnDemand;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: blue;"&gt;var&lt;/SPAN&gt; flayer = &lt;SPAN style="color: blue;"&gt;new&lt;/SPAN&gt; &lt;SPAN style="color: #2b91af;"&gt;FeatureLayer&lt;/SPAN&gt;(featureLayer)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID = layerId.ToString(),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DisplayName = layerName,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IsVisible = &lt;SPAN style="color: blue;"&gt;false&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _mapView.Map.Layers.Add(flayer);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;STRONG&gt;How do i make sure that all 6 layers ends up in the same order that i called them ?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in Advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2015 12:01:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/adding-multiple-layers-in-specific-order/m-p/422282#M5091</guid>
      <dc:creator>BledarBirbo1</dc:creator>
      <dc:date>2015-05-28T12:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: Adding multiple layers in specific ORDER.</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/adding-multiple-layers-in-specific-order/m-p/422283#M5092</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Based on your code, each layer will be added when the OpenAsync call returns. If you want to added them in a specific order you either need to await each call to load_feature_layer_extras, or consider managing the index positions at which you want to insert the layers. The default behavior of ArcGIS is usually to insert layers in this order:&lt;/P&gt;&lt;P&gt;- Points&lt;/P&gt;&lt;P&gt;- Lines&lt;/P&gt;&lt;P&gt;- Polygons&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Therefore you might even consider implementing similar behavior, depending on the context of your app.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2015 12:28:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/adding-multiple-layers-in-specific-order/m-p/422283#M5092</guid>
      <dc:creator>MichaelBranscomb</dc:creator>
      <dc:date>2015-05-28T12:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: Adding multiple layers in specific ORDER.</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/adding-multiple-layers-in-specific-order/m-p/422284#M5093</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mike.&lt;/P&gt;&lt;P&gt;Thanks for your quick reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you please give me more specific directions, or preferably a bit of code for the option "need to await each call to load_feature_layer_extras" ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2015 13:01:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/adding-multiple-layers-in-specific-order/m-p/422284#M5093</guid>
      <dc:creator>BledarBirbo1</dc:creator>
      <dc:date>2015-05-28T13:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: Adding multiple layers in specific ORDER.</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/adding-multiple-layers-in-specific-order/m-p/422285#M5094</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bledar,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think it would be helpful for you to read about asynchronous methods in general, and also specifically about the async-await pattern - &lt;A href="https://msdn.microsoft.com/en-us/library/hh191443.aspx" title="https://msdn.microsoft.com/en-us/library/hh191443.aspx"&gt;Asynchronous Programming with Async and Await (C# and Visual Basic)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; background-color: #f6f6f6;"&gt;Your load_feature_layer_extras &lt;/SPAN&gt;is an asynchronous method, and therefore all the calls to it occur one after the other, but once the execution of each begins - it's impossible to determine which will end first. So what Mike meant is that you can await your calls to the async method, and this will make it behave in a synchronous-like manner - and the order of the calls to the method will also be the order of their execution and the order in which they will end their execution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Miri&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 28 Jun 2015 07:33:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/adding-multiple-layers-in-specific-order/m-p/422285#M5094</guid>
      <dc:creator>MiriRevivo2</dc:creator>
      <dc:date>2015-06-28T07:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: Adding multiple layers in specific ORDER.</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/adding-multiple-layers-in-specific-order/m-p/422286#M5095</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Change this:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: blue;"&gt;private&lt;/SPAN&gt; &lt;SPAN style="color: blue;"&gt;async&lt;/SPAN&gt; &lt;SPAN style="color: blue;"&gt;void&lt;/SPAN&gt; load_feature_layer_extras(&lt;SPAN style="color: blue;"&gt;int&lt;/SPAN&gt; layerId, &lt;SPAN style="color: blue;"&gt;string&lt;/SPAN&gt; layerName)&lt;/P&gt;&lt;P&gt;to this:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: blue;"&gt;private&lt;/SPAN&gt; &lt;SPAN style="color: blue;"&gt;async&lt;/SPAN&gt; &lt;STRONG style="color: blue;"&gt;Task&lt;/STRONG&gt; load_feature_layer_extras(&lt;SPAN style="color: blue;"&gt;int&lt;/SPAN&gt; layerId, &lt;SPAN style="color: blue;"&gt;string&lt;/SPAN&gt; layerName)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And then put "await" in front of all your calls to load_feature_layer_extras.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As much as possible you should/must avoid "async void". It can cause a lot of problem - especially if one layer fails to load. When you can't avoid "async void" (usually in event handlers), make sure you try/catch any awaits.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would really encourage you to watch the following short series on use of async/await:&lt;/P&gt;&lt;P&gt;&lt;A href="https://channel9.msdn.com/Series/Three-Essential-Tips-for-Async" title="https://channel9.msdn.com/Series/Three-Essential-Tips-for-Async"&gt;Six Essential Tips for Async | Channel 9&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jul 2015 19:12:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/adding-multiple-layers-in-specific-order/m-p/422286#M5095</guid>
      <dc:creator>dotMorten_esri</dc:creator>
      <dc:date>2015-07-15T19:12:12Z</dc:date>
    </item>
  </channel>
</rss>

