<?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 Re: How to zoom to a KMLLayer? in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/how-to-zoom-to-a-kmllayer/m-p/38179#M210</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In the sandbox example, change the kml variable scope to a global variable (just remove the var declaration).&lt;/P&gt;&lt;P&gt;Then in the Chrome console, change the console output to log the sandbox's.&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="216621" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/216621_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;Then you can run&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;kml.getLayers() to view the kml layers.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 17 Aug 2016 05:54:37 GMT</pubDate>
    <dc:creator>FC_Basson</dc:creator>
    <dc:date>2016-08-17T05:54:37Z</dc:date>
    <item>
      <title>How to zoom to a KMLLayer?</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-zoom-to-a-kmllayer/m-p/38174#M205</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've created a new KMLLayer, added it to my map, and I can see it once I manually pan and zoom to it. I can't seem to figure out how to programmatically zoom to the new layer. I try to change the map extent to the new layer's extent (e.g.,&amp;nbsp;kmlLayer.fullExtent) but&amp;nbsp;&lt;SPAN&gt;KMLLayer appears to only implement initialExtent, which is huge.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Aug 2016 11:57:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-zoom-to-a-kmllayer/m-p/38174#M205</guid>
      <dc:creator>davidoloughlin</dc:creator>
      <dc:date>2016-08-16T11:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to zoom to a KMLLayer?</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-zoom-to-a-kmllayer/m-p/38175#M206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It seems possible for a vector KML. &amp;nbsp;The API reference page for KML layers (&lt;A class="link-titled" href="https://developers.arcgis.com/javascript/3/jsapi/kmllayer-amd.html" title="https://developers.arcgis.com/javascript/3/jsapi/kmllayer-amd.html" rel="nofollow noopener noreferrer" target="_blank"&gt;KMLLayer | API Reference | ArcGIS API for JavaScript 3.17&lt;/A&gt;&amp;nbsp;) shows how to do it (near the top).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From the API reference page:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4d4d4d; background-color: #ffffff;"&gt;The following code snippet shows how to get a KML layer's layers, checks that a layer has graphics, unions the layer extents and then zooms to the new extent:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN class="" style="color: #595959;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #333333; font-weight: bold;"&gt;var&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt; kmlExtent&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt; layers &lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt; kml&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;getLayers&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;();&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;
&amp;nbsp; dojo&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;forEach&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;layers&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #333333; font-weight: bold;"&gt;function&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;lyr&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;{&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;
&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #333333; font-weight: bold;"&gt;if&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt; lyr&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;graphics &lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;&amp;amp;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt; lyr&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;graphics&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;length &lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #009999;"&gt;0&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;{&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #333333; font-weight: bold;"&gt;var&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt; lyrExtent &lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt; esri&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;geometry&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;geographicToWebMercator&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; esri&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;graphicsExtent&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;lyr&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;graphics&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;);&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #333333; font-weight: bold;"&gt;if&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt; globals&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;kmlExtent &lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;{&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; kmlExtent &lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt; kmlExtent&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="" style="color: #333333; font-weight: bold;"&gt;union&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;lyrExtent&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;);&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;}&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #333333; font-weight: bold;"&gt;else&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;{&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; kmlExtent &lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt; lyrExtent&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;;&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;}&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;
&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;});&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;
&amp;nbsp; map&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;setExtent&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959;"&gt;kmlExtent&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is your KML layer a ground overlay?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:29:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-zoom-to-a-kmllayer/m-p/38175#M206</guid>
      <dc:creator>FC_Basson</dc:creator>
      <dc:date>2021-12-10T21:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to zoom to a KMLLayer?</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-zoom-to-a-kmllayer/m-p/38176#M207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks very much for the code snippet. I've tried using ground overlays but also just a simple polygon, Wyoming.kml used&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/3/jssamples/layers_kml.html"&gt;here&lt;/A&gt;. In both cases,&amp;nbsp;kml.getLayers() returns [], &amp;nbsp;no layers to iterate through.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Aug 2016 13:15:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-zoom-to-a-kmllayer/m-p/38176#M207</guid>
      <dc:creator>davidoloughlin</dc:creator>
      <dc:date>2016-08-16T13:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to zoom to a KMLLayer?</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-zoom-to-a-kmllayer/m-p/38177#M208</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you tried your KML source in the sandbox example? &amp;nbsp;That kml returns an array with a single layer object.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Aug 2016 13:26:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-zoom-to-a-kmllayer/m-p/38177#M208</guid>
      <dc:creator>FC_Basson</dc:creator>
      <dc:date>2016-08-16T13:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to zoom to a KMLLayer?</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-zoom-to-a-kmllayer/m-p/38178#M209</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks very much for your patience. I'm obviously missing something but how can you tell? I modify this&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/3/sandbox/sandbox.html?sample=layers_kml"&gt;sandbox example&lt;/A&gt;, adding the line 'console.log(kml.getLayers())' below the line 'map.addLayer(kml);', then run it. Looking at the console (in chrome anyway), I just see '[]'.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Aug 2016 13:55:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-zoom-to-a-kmllayer/m-p/38178#M209</guid>
      <dc:creator>davidoloughlin</dc:creator>
      <dc:date>2016-08-16T13:55:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to zoom to a KMLLayer?</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-zoom-to-a-kmllayer/m-p/38179#M210</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In the sandbox example, change the kml variable scope to a global variable (just remove the var declaration).&lt;/P&gt;&lt;P&gt;Then in the Chrome console, change the console output to log the sandbox's.&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="216621" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/216621_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;Then you can run&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;kml.getLayers() to view the kml layers.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Aug 2016 05:54:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-zoom-to-a-kmllayer/m-p/38179#M210</guid>
      <dc:creator>FC_Basson</dc:creator>
      <dc:date>2016-08-17T05:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to zoom to a KMLLayer?</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-zoom-to-a-kmllayer/m-p/38180#M211</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. That explains it. Needed to move my&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;kml.getLayers() loop into the&amp;nbsp;"load" event handler function.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Aug 2016 12:44:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-zoom-to-a-kmllayer/m-p/38180#M211</guid>
      <dc:creator>davidoloughlin</dc:creator>
      <dc:date>2016-08-17T12:44:57Z</dc:date>
    </item>
  </channel>
</rss>

