Get nothing from the localserver service (v.100)

1327
4
Jump to solution
04-21-2017 02:27 AM
Pierre-JeanMuller
New Contributor III

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.

private Esri.ArcGISRuntime.LocalServices.LocalServer _localServer;
ArcGISMapImageLayer localServiceLayer;
private async void StartLocalServer()
        {
            // Get the singleton LocalServer object using the static "Instance" property
            _localServer = Esri.ArcGISRuntime.LocalServices.LocalServer.Instance;

            //_localServer.AppDataPath = @"C:\Temp\localserver";

            // Handle the StatusChanged event to react when the server is started
            _localServer.StatusChanged += ServerStatusChanged;

            // Start the local server instance
            await _localServer.StartAsync();
        }

private void ServerStatusChanged(object sender, Esri.ArcGISRuntime.LocalServices.StatusChangedEventArgs e)
        {
            // Check if the server started successfully
            if (e.Status == Esri.ArcGISRuntime.LocalServices.LocalServerStatus.Started)
            {
                LocalMapService localmapService = new LocalMapService(@"G:\GISData\myData.mpk");

                //MessageBox.Show(localmapService.Status.ToString());
                localmapService.StatusChanged += (svc, args) =>
                {
                    //MessageBox.Show(localmapService.Status.ToString());

                    // If started successfully, add a layer from the service
                    if (args.Status == LocalServerStatus.Started)
                    {
                        // Get the service URL
                        var mapServiceUrl = (svc as LocalMapService).Url;

                        // Create a new ArcGISMapImageLayer
                        localServiceLayer = new ArcGISMapImageLayer(mapServiceUrl);


                        localServiceLayer.LoadAsync();

                        // Set layer opacity to semi-transparent
                        localServiceLayer.Opacity = 1;

                        // Add the layer to the map
                        MainMapView.Map.OperationalLayers.Add(localServiceLayer);
                    }
                };
                // Start the local map service
                localmapService.StartAsync();
            }
        }
0 Kudos
1 Solution

Accepted Solutions
Pierre-JeanMuller
New Contributor III

I got it, the data have to be projected to mercator, if not, it is not visualised. I don't know if it is an error or a prerequest for the localserver

View solution in original post

0 Kudos
4 Replies
Pierre-JeanMuller
New Contributor III

Just to add some details that may help finding a solution :

When I look to the Image layer parameters, I find this in the "Spatial reference" field : SpatialReference = 'localServiceLayer.SpatialReference' threw an exception of type 'System.InvalidOperationException'

If I use mpkx file (resulted from arcgis pro), I got : Failed to create service delme MapServer. Service failed to initialize: IObjectConstruct::Construct (MapServer) hr=0x80043000 (ErrorInfo did not include a description)

0 Kudos
Pierre-JeanMuller
New Contributor III

I got it, the data have to be projected to mercator, if not, it is not visualised. I don't know if it is an error or a prerequest for the localserver

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

Hi,

The ArcGISMapImageLayer should request a map image from the LocalMapServices in the spatial reference of the MapView so this might be a bug (although we do always recommend that your data should share a common spatial reference, to avoid the overhead of reprojecting on the fly).

What data formats/types are in your MPK and what other layers are in your Map (both basemap and operational)?

Cheers

Mike 

0 Kudos
Pierre-JeanMuller
New Contributor III

Hi,

thanks for your answer. In fact, I can understand that a .mpk file has to use the same spatial reference as the MapView, but I only expected to get some error message.

In my MapView, I has one elevation layer of WGS84(4326) from an arcgis server + graphics layer + openstreetmap layer.

In the mpk, I had WGS84(4326) layer. I reproject it to epsg:3857 to be able to visualise it.

0 Kudos