Currently moving from Runtime 10.1.1 to 100.1 ...
10.1.1 Code to load Rest Basemap was...
Dim NewTiledLayer As New ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer() With NewTiledLayer .Url = "https://mapgenie.osi.ie/arcgis/rest/services/WM/basemap_premium/MapServer " .Token = "abcdefghigh123456789" End WithMyMap.Layers.Add(NewTiledLayer)
What is the equivalent code in 100.1 ?
In v100.x, you no longer set a Token property. You may set Credential or implement ChallengeHandler.
AuthenticationManager<SPAN class="punctuation token">.</SPAN>Current<SPAN class="punctuation token">.</SPAN>ChallengeHandler <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">ChallengeHandler</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">async</SPAN> <SPAN class="punctuation token">(</SPAN>info<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="comment token">// Option A: Use ChallengeHandler to prompt for login</SPAN> <SPAN class="keyword token">return</SPAN> <SPAN class="keyword token">await</SPAN> AuthenticationManager<SPAN class="punctuation token">.</SPAN>Current<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GenerateCredentialAsync</SPAN><SPAN class="punctuation token">(</SPAN>info<SPAN class="punctuation token">.</SPAN>ServiceUri<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"username"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"password"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> layer <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">ArcGISMapImageLayer</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">Uri</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token"><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fsampleserver6.arcgisonline.com%2Farcgis%2Frest%2Fservices%2FWildfire_secure%2FMapServer" target="_blank">http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire_secure/MapServer</A><SPAN>"</SPAN></SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// Option B: Set Credential property</SPAN> layer<SPAN class="punctuation token">.</SPAN>Credential <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">await</SPAN> AuthenticationManager<SPAN class="punctuation token">.</SPAN>Current<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GenerateCredentialAsync</SPAN><SPAN class="punctuation token">(</SPAN>layer<SPAN class="punctuation token">.</SPAN>Source<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"user1"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"user1"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> MyMapView<SPAN class="punctuation token">.</SPAN>Map <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">Map</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">Basemap</SPAN><SPAN class="punctuation token">(</SPAN>layer<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.