AnsweredAssumed Answered

Showing Layer on SceneView works in Windows XAML but not iOS

Question asked by torenthal on Dec 10, 2019
Latest reply on Dec 13, 2019 by torenthal

My goal is to load a KML file to display a layer on a SceneView using C# and Arcgis in both Windows and iOS.

 

The following code works in Windows XAML but it does not work on iOS.

 

// Create a new basemap.
Basemap imageryBasemap = Basemap.CreateImageryWithLabels();

// Create and show a new scene with imagery basemap.
MySceneView.Scene = new Scene(imageryBasemap);

 

KmlLayer layer;

layer = new KmlLayer(new Uri(name)); //name is a local filename

 

// Add the selected layer to the map.
MySceneView.Scene.OperationalLayers.Add(layer);
await layer.LoadAsync();

await MySceneView.SetViewpointAsync(new Viewpoint(layer.FullExtent));

 

This displays a KML layer at a specific location and zooms into it.

 

--------------------------------------------

 

Using iOS, the file has been included in the application package in a kml directory bundled with the application.

 

// Create a new basemap.
Basemap imageryBasemap = Basemap.CreateImageryWithLabels();

// Create and show a new scene with imagery basemap.
MySceneView.Scene = new Scene(imageryBasemap);

 

KmlLayer layer;
try
{
   var uriname = new Uri("file:///./kml/mylayer.kml");
   layer = new KmlLayer(uriname);
}
catch (Exception e)
{
    Console.WriteLine("ERROR OPENING KML FILE: {0}", e.Message);  // No error here.
    return;
}

 

Console.WriteLine("KML FILE named {0} loaded...", layer.Name); // layer has no Name here which indicates to me that although the above didn't throw an exception the layer wasn't actually loaded.

 

// Add the selected layer to the map.
MySceneView.Scene.OperationalLayers.Add(layer);

 

// Zoomed into the approximate area but there is no layer shown on the map.

 

Envelope myEnvelope = new Envelope(-118.45, 45.92, -118.42, 45.95, SpatialReferences.Wgs84);
MySceneView.SetViewpointAsync(new Viewpoint(myEnvelope));

 

Any help is appreciated.

 

Also, any help to load a KmlLayer from a local data element or stream rather than from a URI would be great.

Outcomes