<?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: Setting map extent to dynamic layer's initial extent doesn't always work in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-map-extent-to-dynamic-layer-s-initial/m-p/746558#M69088</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This problem was eventually solved by wrapping the map initialization in a setTimeout function. The root of the problem seemed to be that the project has two scripts. The first reads in the configuration file using esriRequest and the second does the map initialization based on values read from the configuration file. It seems the map initialization was happening before the request was finished. Rewriting the code into a single script solved the problem in the end.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 09 Sep 2013 18:51:07 GMT</pubDate>
    <dc:creator>KenBuja</dc:creator>
    <dc:date>2013-09-09T18:51:07Z</dc:date>
    <item>
      <title>Setting map extent to dynamic layer's initial extent doesn't always work</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-map-extent-to-dynamic-layer-s-initial/m-p/746554#M69084</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm setting the map extent to a dynamic layer once it's loaded using the following code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; layerDynamic.on("load", function () { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var deferred = new Deferred(); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; deferred = map.setExtent(layerDynamic.initialExtent, true); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; deferred.then(function () { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log("map xmin: " + map.extent.xmin + ", ymin: " + map.extent.ymin + ", xmax: " + map.extent.xmax + ", ymax: " + map.extent.ymax) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log("layer xmin: " + layerDynamic.initialExtent.xmin + ", ymin: " + layerDynamic.initialExtent.ymin + ", xmax: " + layerDynamic.initialExtent.xmax + ", ymax: " + layerDynamic.initialExtent.ymax) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }); &amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, this doesn't always work. When I refresh the page, it often zooms out way too far. This is what the extents usually are when it doesn't zoom correctly&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;map xmin: -27374674.768619433, ymin: -2290122.0955929635, xmax: -6828401.565569537, ymax: 6241473.253482993 layer xmin: -14166895.9892999, ymin: 5762234.783315, xmax: -13598348.0746001, ymax: 6211946.863385&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Why doesn't that code work upon a refresh?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Jul 2013 20:15:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-map-extent-to-dynamic-layer-s-initial/m-p/746554#M69084</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2013-07-30T20:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: Setting map extent to dynamic layer's initial extent doesn't always work</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-map-extent-to-dynamic-layer-s-initial/m-p/746555#M69085</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ken,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;initialExtent is the extent of the mxd when published.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try fullExtent, which is the extent of the data.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;map.setExtent(layerDynamic.fullExtent, true);&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Jul 2013 21:18:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-map-extent-to-dynamic-layer-s-initial/m-p/746555#M69085</guid>
      <dc:creator>BenFousek</dc:creator>
      <dc:date>2013-07-30T21:18:09Z</dc:date>
    </item>
    <item>
      <title>Re: Setting map extent to dynamic layer's initial extent doesn't always work</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-map-extent-to-dynamic-layer-s-initial/m-p/746556#M69086</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Ken,&lt;BR /&gt;&lt;BR /&gt;initialExtent is the extent of the mxd when published.&lt;BR /&gt;&lt;BR /&gt;Try fullExtent, which is the extent of the data.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;map.setExtent(layerDynamic.fullExtent, true);&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks Ben, but I do want the initial extent rather than the full extent of the service. And in the case of this particular service, the initial extent is not that much different than the full extent&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;&lt;STRONG&gt;Initial Extent:&lt;/STRONG&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;UL&gt;XMin: -14166895.9892999&lt;BR /&gt;YM in: 5762234.783315&lt;BR /&gt;XMax: -13598348.0746001&lt;BR /&gt;YMax: 6211946.863385&lt;BR /&gt;Spatial Reference: 102100 (3857)&lt;BR /&gt;&lt;/UL&gt; &lt;STRONG&gt;Full Extent:&lt;/STRONG&gt; &lt;BR /&gt; [INDENT]&lt;BR /&gt;XMin: -14015721.4263&lt;BR /&gt;YMin: 5782676.2415&lt;BR /&gt;XMax: -13749522.6376&lt;BR /&gt;YMax: 6191505.4052&lt;BR /&gt;Spatial Reference: 102100 (3857)&lt;BR /&gt;[/INDENT]&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Jul 2013 11:54:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-map-extent-to-dynamic-layer-s-initial/m-p/746556#M69086</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2013-07-31T11:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: Setting map extent to dynamic layer's initial extent doesn't always work</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-map-extent-to-dynamic-layer-s-initial/m-p/746557#M69087</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In general, I prefer fullExtent because some 3rd party map services are published with strange extents, e.g. zoomed way in outside the data extent.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tested this in an app and it worked fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;vmc.on('load', function() {
&amp;nbsp; app.map.setExtent(vmc.initialExtent, true);
});&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is the deferred necessary? Using your code didn't work for me.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:45:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-map-extent-to-dynamic-layer-s-initial/m-p/746557#M69087</guid>
      <dc:creator>BenFousek</dc:creator>
      <dc:date>2021-12-12T07:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: Setting map extent to dynamic layer's initial extent doesn't always work</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-map-extent-to-dynamic-layer-s-initial/m-p/746558#M69088</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This problem was eventually solved by wrapping the map initialization in a setTimeout function. The root of the problem seemed to be that the project has two scripts. The first reads in the configuration file using esriRequest and the second does the map initialization based on values read from the configuration file. It seems the map initialization was happening before the request was finished. Rewriting the code into a single script solved the problem in the end.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Sep 2013 18:51:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-map-extent-to-dynamic-layer-s-initial/m-p/746558#M69088</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2013-09-09T18:51:07Z</dc:date>
    </item>
  </channel>
</rss>

