POST
|
Hi Morten, Here's a link to the KMZ file: http://images.pollensystems.com/kml/arcgis_extent_error.kmz Thanks for any assistance! Keith
... View more
02-12-2020
04:46 PM
|
0
|
0
|
910
|
POST
|
In the following code on SDK 100.xxx on an IOS device, FullExtent is populated to 180, 90, -180, -90 which does not really help when you're trying to zoom to a layer. FullExtent for this layer should be returning 18.8404922485352, -33.0619621276855, 18.8464298248291, -33.0554275512695 The KMZ layer loads and displays on the SceneView no problem. The below code snippet results in: 2020-02-12 07:08:50.546 PrecisionView[779:912352] Extent: Xmax 180, Ymax 90, Xmin -180, Ymin -90 As a workaround, I'm having to load and read the coordinates from the actual file which is an unnecessary performance hit. Is FullExtent not populating a known bug or what am I missing to get FullExtent of a layer to populate correctly? ************************************************************ bool extenthasvalues = false; Console.WriteLine("Loading layer..."); await Layer.Layer.Dataset.LoadAsync(); // Wait for layer data to load in var extent = Layer.Layer.FullExtent; Console.WriteLine("Extent: Xmax {0}, Ymax {1}, Xmin {2}, Ymin {3}", extent.XMax, extent.YMax, extent.XMin, extent.YMin); if (extent.XMax != 180) // Addressing bug in Arcgis { r.maxLatitude = extent.XMax; r.maxLongitude = extent.YMax; r.minLatitude = extent.XMin; r.minLongitude = extent.YMin; extenthasvalues = true; } if (!extenthasvalues) { Console.WriteLine("Fullextent has no values. Getting coordinates from {0}...", Layer.UriPath); if (Layer.Coordinates == null) { Layer.Coordinates = LoadCoordinatesFromUri(Layer); } r = KML.GetRange(Layer.Coordinates); } ************************************************************
... View more
02-12-2020
07:16 AM
|
0
|
3
|
941
|
POST
|
Thanks that was a good suggestion. I tried that but still have the same problem on IOS. The call fails at layer = new KmlLayer(uriname); I have tried all variants of the file name I can think of, including getting IOS to resolve the path from the file attributes. The KML layer file is not found by the call to load it. Here is the code: Console.WriteLine("------------------------ Can I read the file attributes to find the file name I should be loading??? ---------------------------"); listallfiles(); Console.WriteLine("------------------------ Confirmed ---------------------------------------------"); var text = File.ReadAllText("kml/SevenHills.kml"); Console.WriteLine("------------------------ Can I read the file data??? ---------------------------"); Console.WriteLine(text); Console.WriteLine("------------------------ Confirmed ---------------------------------------------"); string apppath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)+"PrecisionView.app/"; KmlLayer layer; try { ///private/var/containers/Bundle/Application/0DE39905-B65F-4D3B-89E8-03733F22CD97/PrecisionView.app/kml //BAD: file:///var/mobile/Containers/Data/Application/0EA9D36C-0FCF-470F-8330-A05AB0EB8078/DocumentsPrecisionView.app//PrecisionView.app/kml/SevenHills.kml //string uripath = String.Format("file://{0}/{1}", apppath, "PrecisionView.app/kml/SevenHills.kml"); string uripath = String.Format("/private/var/containers/Bundle/Application/2B4FAC7A-2D95-4930-B8B3-EDB74E5EE5C1/PrecisionView.app/kml/SevenHills.kml"); Console.WriteLine("------------------------ Can I load the layer??? ---------------------------"); Console.WriteLine("Opening layer at {0}", uripath); var uriname = new Uri(uripath); Console.WriteLine("Got uriname *{0}*", uriname); layer = new KmlLayer(uriname); await layer.Dataset.LoadAsync(); // Add the selected layer to the map. MySceneView.Scene.OperationalLayers.Add(layer); } catch (Exception e) { Console.WriteLine("ERROR OPENING KML LAYER: {0}", e.Message); } Code output... ------------------------ Can I read the file attributes to find the file name I should be loading??? --------------------------- File entry /private/var/containers/Bundle/Application/575AAF82-F750-4EC5-B447-519B475B5162/PrecisionView.app/kml/SevenHills.kml was created on Tuesday, December 10, 2019 ------------------------ Confirmed --------------------------------------------- ------------------------ Can I read the file data??? --------------------------- <?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"> <Document> <name>SevenHills.kml</name> <Style id="s_ylw-pushpin"> <IconStyle> <scale>1.1</scale> <Icon> <href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href> </Icon> <hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/> </IconStyle> </Style> <StyleMap id="m_ylw-pushpin"> <Pair> <key>normal</key> <styleUrl>#s_ylw-pushpin</styleUrl> </Pair> <Pair> <key>highlight</key> <styleUrl>#s_ylw-pushpin_hl</styleUrl> </Pair> </StyleMap> <Style id="s_ylw-pushpin_hl"> <IconStyle> <scale>1.3</scale> <Icon> <href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href> </Icon> <hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/> </IconStyle> </Style> <Placemark> <name>SevenHills</name> <styleUrl>#m_ylw-pushpin</styleUrl> <LineString> <tessellate>1</tessellate> <coordinates> -118.4446238031191,45.94000421858365,0 -118.4450094178675,45.93994794787083,0 -118.4498222134527,45.93992062957039,0 -118.4500906993986,45.93985975936327,0 -118.4505174909842,45.93983704458147,0 -118.4506740720017,45.93984775259004,0 -118.4525384944131,45.94040390603141,0 -118.4529241486569,45.94065919135618,0 -118.453620877357,45.94091070219196,0 -118.4547612503623,45.94172367299246,0 -118.4550541786503,45.94188449253917,0 -118.455239083684,45.94199524572046,0 -118.4555545265985,45.94236607539884,0 -118.4559509010189,45.94274036876337,0 -118.4560208178186,45.94329440929713,0 -118.4560468388909,45.94360971654032,0 -118.4561156245048,45.94385465236871,0 -118.4560522801767,45.94408463509967,0 -118.4551206805496,45.94530381009788,0 -118.4533325449118,45.94740862523928,0 -118.4518443683923,45.94898830919681,0 -118.4514731586695,45.94944601639191,0 -118.451028383202,45.94974797366869,0 -1 18.4493239543043,45.95048011909979,0 -118.4477220268395,45.95113079524753,0 -118.447339088874,45.95108785542429,0 -118.4468485708434,45.95039280290377,0 -118.4466113293553,45.95011731022146,0 -118.446356216983,45.94994690914195,0 -118.4461523221155,45.94982942741466,0 -118.4460285096415,45.94968884730044,0 -118.4460329814595,45.94956775407266,0 -118.4461439704801,45.94927619962923,0 -118.4460596672124,45.94916727943071,0 -118.4458574282867,45.94914489020882,0 -118.4455750473521,45.94914791492524,0 -118.4453368324822,45.94898700191206,0 -118.4449551293189,45.94896331920968,0 -118.4444213851763,45.94890554776818,0 -118.4439528720892,45.94885975957928,0 -118.4434563634693,45.94887390132582,0 -118.4430032656326,45.94888625665448,0 -118.442772548067,45.94888083432534,0 -118.4426436296657,45.94876062941377,0 -118.4426003787763,45.94855011202757,0 -118.4424216099796,45.94834787625387,0 -118.4420682021547,45.94809749861648,0 -118.4418570593747,45.94794806768007,0 -118.4416575461201,45.94781784342278,0 -118.4415081315 729,45.94770373683252,0 -118.4415404378177,45.94735740639674,0 -118.4446230976549,45.94733122500705,0 -118.4445857085007,45.94605786991772,0 -118.4446238031191,45.94000421858365,0 </coordinates> </LineString> </Placemark> </Document> </kml> ------------------------ Confirmed --------------------------------------------- ------------------------ Can I load the layer??? --------------------------- Opening layer at /private/var/containers/Bundle/Application/2B4FAC7A-2D95-4930-B8B3-EDB74E5EE5C1/PrecisionView.app/kml/SevenHills.kml Got uriname *file:///private/var/containers/Bundle/Application/2B4FAC7A-2D95-4930-B8B3-EDB74E5EE5C1/PrecisionView.app/kml/SevenHills.kml* ERROR OPENING KML LAYER: File not found
... View more
12-13-2019
06:13 PM
|
0
|
0
|
450
|
POST
|
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.
... View more
12-10-2019
05:57 PM
|
0
|
2
|
510
|
Online Status |
Offline
|
Date Last Visited |
07-06-2022
01:36 PM
|