Hello,
I am trying to use the local server. The service is starting without errors, but it is not visible when added to the map.
<SPAN class="keyword token">private</SPAN> Esri<SPAN class="punctuation token">.</SPAN>ArcGISRuntime<SPAN class="punctuation token">.</SPAN>LocalServices<SPAN class="punctuation token">.</SPAN>LocalServer _localServer<SPAN class="punctuation token">;</SPAN>
ArcGISMapImageLayer localServiceLayer<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">private</SPAN> <SPAN class="keyword token">async</SPAN> <SPAN class="keyword token">void</SPAN> <SPAN class="token function">StartLocalServer</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">// Get the singleton LocalServer object using the static "Instance" property</SPAN>
_localServer <SPAN class="operator token">=</SPAN> Esri<SPAN class="punctuation token">.</SPAN>ArcGISRuntime<SPAN class="punctuation token">.</SPAN>LocalServices<SPAN class="punctuation token">.</SPAN>LocalServer<SPAN class="punctuation token">.</SPAN>Instance<SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//_localServer.AppDataPath = @"C:\Temp\localserver";</SPAN>
<SPAN class="comment token">// Handle the StatusChanged event to react when the server is started</SPAN>
_localServer<SPAN class="punctuation token">.</SPAN>StatusChanged <SPAN class="operator token">+</SPAN><SPAN class="operator token">=</SPAN> ServerStatusChanged<SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Start the local server instance</SPAN>
<SPAN class="keyword token">await</SPAN> _localServer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">StartAsync</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">private</SPAN> <SPAN class="keyword token">void</SPAN> <SPAN class="token function">ServerStatusChanged</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">object</SPAN> sender<SPAN class="punctuation token">,</SPAN> Esri<SPAN class="punctuation token">.</SPAN>ArcGISRuntime<SPAN class="punctuation token">.</SPAN>LocalServices<SPAN class="punctuation token">.</SPAN>StatusChangedEventArgs e<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">// Check if the server started successfully</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>e<SPAN class="punctuation token">.</SPAN>Status <SPAN class="operator token">==</SPAN> Esri<SPAN class="punctuation token">.</SPAN>ArcGISRuntime<SPAN class="punctuation token">.</SPAN>LocalServices<SPAN class="punctuation token">.</SPAN>LocalServerStatus<SPAN class="punctuation token">.</SPAN>Started<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
LocalMapService localmapService <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">LocalMapService</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">@"G:\GISData\myData.mpk"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//MessageBox.Show(localmapService.Status.ToString());</SPAN>
localmapService<SPAN class="punctuation token">.</SPAN>StatusChanged <SPAN class="operator token">+</SPAN><SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>svc<SPAN class="punctuation token">,</SPAN> args<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">//MessageBox.Show(localmapService.Status.ToString());</SPAN>
<SPAN class="comment token">// If started successfully, add a layer from the service</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>args<SPAN class="punctuation token">.</SPAN>Status <SPAN class="operator token">==</SPAN> LocalServerStatus<SPAN class="punctuation token">.</SPAN>Started<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">// Get the service URL</SPAN>
<SPAN class="keyword token">var</SPAN> mapServiceUrl <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>svc <SPAN class="keyword token">as</SPAN> LocalMapService<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>Url<SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Create a new ArcGISMapImageLayer</SPAN>
localServiceLayer <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">ArcGISMapImageLayer</SPAN><SPAN class="punctuation token">(</SPAN>mapServiceUrl<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
localServiceLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">LoadAsync</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Set layer opacity to semi-transparent</SPAN>
localServiceLayer<SPAN class="punctuation token">.</SPAN>Opacity <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Add the layer to the map</SPAN>
MainMapView<SPAN class="punctuation token">.</SPAN>Map<SPAN class="punctuation token">.</SPAN>OperationalLayers<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Add</SPAN><SPAN class="punctuation token">(</SPAN>localServiceLayer<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="comment token">// Start the local map service</SPAN>
localmapService<SPAN class="punctuation token">.</SPAN><SPAN class="token function">StartAsync</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="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>