<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to get Geometry from KmlNode in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-get-geometry-from-kmlnode/m-p/1022931#M9754</link>
    <description>&lt;P&gt;Hello, I'm new with the ArcGIS SDK and try to find a way how to get the Geometry from a KmlNode, respectively from a kml file.&lt;/P&gt;&lt;P&gt;The general idea is to show to whole KmlNode structure from the kml file in a XAML TreeView and when you click on an item it should extract the Geometry.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Uri kmlUri = new Uri(path);
KmlDataset dataset = new KmlDataset(kmlUri);
KmlLayer layer = new KmlLayer(dataset);
MyMapView.Map.OperationalLayers.Add(layer);

foreach (KmlNode kmlRootNode in dataset.RootNodes)
{
  KmlPlacemark kmlPlacemark = kmlRootNode as KmlPlacemark;
  Geometry geometry = kmlPlacemark.Geometry;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cast the KmlNode as a KmlPlacemark correctly, but the Geometry is ALWAYS null, I don't know why. Everything else like the GrahicType, the BalloonContent or the Extent of the KmlPlacemark are correct.&lt;/P&gt;&lt;P&gt;Does somebody have a hint for me what I am doing wrong or how I can solve this issue?&lt;/P&gt;&lt;P&gt;Thanks in advance.&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 03 Feb 2021 11:07:38 GMT</pubDate>
    <dc:creator>RobWag</dc:creator>
    <dc:date>2021-02-03T11:07:38Z</dc:date>
    <item>
      <title>How to get Geometry from KmlNode</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-get-geometry-from-kmlnode/m-p/1022931#M9754</link>
      <description>&lt;P&gt;Hello, I'm new with the ArcGIS SDK and try to find a way how to get the Geometry from a KmlNode, respectively from a kml file.&lt;/P&gt;&lt;P&gt;The general idea is to show to whole KmlNode structure from the kml file in a XAML TreeView and when you click on an item it should extract the Geometry.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Uri kmlUri = new Uri(path);
KmlDataset dataset = new KmlDataset(kmlUri);
KmlLayer layer = new KmlLayer(dataset);
MyMapView.Map.OperationalLayers.Add(layer);

foreach (KmlNode kmlRootNode in dataset.RootNodes)
{
  KmlPlacemark kmlPlacemark = kmlRootNode as KmlPlacemark;
  Geometry geometry = kmlPlacemark.Geometry;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cast the KmlNode as a KmlPlacemark correctly, but the Geometry is ALWAYS null, I don't know why. Everything else like the GrahicType, the BalloonContent or the Extent of the KmlPlacemark are correct.&lt;/P&gt;&lt;P&gt;Does somebody have a hint for me what I am doing wrong or how I can solve this issue?&lt;/P&gt;&lt;P&gt;Thanks in advance.&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 11:07:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-get-geometry-from-kmlnode/m-p/1022931#M9754</guid>
      <dc:creator>RobWag</dc:creator>
      <dc:date>2021-02-03T11:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Geometry from KmlNode</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-get-geometry-from-kmlnode/m-p/1023059#M9757</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is the RootNode definitely of type KmlPlacemark? I recommend conditionally checking for the type of each node, noting that some may be containers (e.g. KmlFolder) containing collections of nodes, or other containers, etc.&lt;/P&gt;&lt;P&gt;Also, although you add the layer to the view, it may still be loading when the next line tries to iterate the rootnode. You should await the KmlDataset LoadAsync e.g. `await dataset.LoadAsync();`. Alternatively you can add an event handler for the LoadStatusChanged event.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 17:19:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-get-geometry-from-kmlnode/m-p/1023059#M9757</guid>
      <dc:creator>MichaelBranscomb</dc:creator>
      <dc:date>2021-02-03T17:19:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Geometry from KmlNode</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-get-geometry-from-kmlnode/m-p/1023084#M9759</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;thanks for your reply. For the sake of simplicity I only copy &amp;amp; pasted the important parts of the code.&lt;/P&gt;&lt;P&gt;The more detailed code would be:&lt;/P&gt;&lt;P&gt;I first load the kml file with an open file dialog. And when the loading succeeds, I create the dataset and the layer:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;string path = openFileDialog.FileName;
Uri kmlUri = new Uri(path);
KmlDataset dataset = new KmlDataset(kmlUri);
KmlLayer layer = new KmlLayer(dataset);
MyMapView.Map.OperationalLayers.Add(layer);
await LoadKmlData(dataset);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The method LoadKmlData would add all the KmlNodes to the WPF/XAML TreeView:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;await dataset.LoadAsync();
foreach (KmlNode kmlRootNode in dataset.RootNodes)
{
   TreeViewItem treeViewItem = new TreeViewItem(kmlRootNode, null);
   treeViewItems.Add(treeViewItem);
   TreeViewItem.AddChildrenItemsToRootItem(treeViewItem);
}
TreeView.ItemsSource = treeViewItems;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The TreeView shows all the items from my kml file correctly. When I click on a TreeView item, I would like to get the Geometry of that item by the Event handler&amp;nbsp;TreeView_SelectedItemChanged:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;TreeViewItem selectedItem = e.NewValue as TreeViewItem;
if(selectedItem != null)
{
   KmlNode node = selectedItem.Node;
   if(node.GetType() == typeof(KmlPlacemark))
   {
      Geometry geometry = ((KmlPlacemark)node).Geometry;
   }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;But unfortunately the geometry is null.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 17:54:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-get-geometry-from-kmlnode/m-p/1023084#M9759</guid>
      <dc:creator>RobWag</dc:creator>
      <dc:date>2021-02-03T17:54:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Geometry from KmlNode</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-get-geometry-from-kmlnode/m-p/1023109#M9761</link>
      <description>&lt;P&gt;Try the .Geometries property instead. They are slightly different. See the doc:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MortenNielsen_0-1612376683305.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/5239i910B51AC3DEBEFE7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MortenNielsen_0-1612376683305.png" alt="MortenNielsen_0-1612376683305.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 18:24:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-get-geometry-from-kmlnode/m-p/1023109#M9761</guid>
      <dc:creator>dotMorten_esri</dc:creator>
      <dc:date>2021-02-03T18:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Geometry from KmlNode</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-get-geometry-from-kmlnode/m-p/1023826#M9771</link>
      <description>&lt;P&gt;Cool, that helped a lot. Thank you very much.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 10:32:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-get-geometry-from-kmlnode/m-p/1023826#M9771</guid>
      <dc:creator>RobWag</dc:creator>
      <dc:date>2021-02-05T10:32:07Z</dc:date>
    </item>
  </channel>
</rss>

