<?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 KML string to KmlLayer in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/kml-string-to-kmllayer/m-p/333284#M3922</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've seen that similar questions have been asked, bust most of them are over a year old. Is there a way to add a KmlLayer from a KML string or a local file?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried the following, but it only works when file is a url. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;string file = @"C:\devel\test.kml";
KmlLayer kmlLayer = new KmlLayer(new Uri(file));
MyMapView.Map.Layers.Add(kmlLayer);&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 15:46:48 GMT</pubDate>
    <dc:creator>JasonTrinidad1</dc:creator>
    <dc:date>2021-12-11T15:46:48Z</dc:date>
    <item>
      <title>KML string to KmlLayer</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/kml-string-to-kmllayer/m-p/333284#M3922</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've seen that similar questions have been asked, bust most of them are over a year old. Is there a way to add a KmlLayer from a KML string or a local file?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried the following, but it only works when file is a url. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;string file = @"C:\devel\test.kml";
KmlLayer kmlLayer = new KmlLayer(new Uri(file));
MyMapView.Map.Layers.Add(kmlLayer);&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:46:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/kml-string-to-kmllayer/m-p/333284#M3922</guid>
      <dc:creator>JasonTrinidad1</dc:creator>
      <dc:date>2021-12-11T15:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: KML string to KmlLayer</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/kml-string-to-kmllayer/m-p/333285#M3923</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jason,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think it only takes a URI, you have to convert it no matter what the source is. Here's their official example of dragging and dropping a local file to the Map, and it looks like they did the same thing you did:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;private async void MyMapView_Drop(object sender, DragEventArgs e)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (e.Data.GetDataPresent(DataFormats.FileDrop))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; KmlLayer kmlLayer = new KmlLayer(new Uri(files[0]));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; await kmlLayer.InitializeAsync();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Add the kml layer
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyMapView.Map.Layers.Add(kmlLayer);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Zoom to the kml layer if available
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (kmlLayer.RootFeature.Viewpoint != null)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; await MyMapView.SetViewAsync(kmlLayer.RootFeature.Viewpoint);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
}&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:46:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/kml-string-to-kmllayer/m-p/333285#M3923</guid>
      <dc:creator>KennethLathan</dc:creator>
      <dc:date>2021-12-11T15:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: KML string to KmlLayer</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/kml-string-to-kmllayer/m-p/333286#M3924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For anyone interested, I was able to make it work by adding the KML layer with&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MyMap.Layers.Add(kmlLayer);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;instead of&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MyMapView.Map.Layers.Add(kmlLayer);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;string file = @"C:\devel\test.kml"; 
KmlLayer kmlLayer = new KmlLayer(new Uri(file));
MyMap.Layers.Add(kmlLayer); &lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wasn't able to do it with a string, but a file is good enough.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:46:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/kml-string-to-kmllayer/m-p/333286#M3924</guid>
      <dc:creator>JasonTrinidad1</dc:creator>
      <dc:date>2021-12-11T15:46:54Z</dc:date>
    </item>
  </channel>
</rss>

