<?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: Set initial extent on page load in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/set-initial-extent-on-page-load/m-p/1689956#M88287</link>
    <description>&lt;LI-CODE lang="javascript"&gt;const mapElement = document.getElementById("yourMap");

await mapElement.componentOnReady();

mapElement.center = [-95.38, 39.23];

// Set scale at the view. 
const view = mapElement.view;
view.scale = 560000; &lt;/LI-CODE&gt;&lt;P&gt;OR&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;mapElement.extent = {
  xmin: -95.50,
  ymin: 39.15,
  xmax: -95.20,
  ymax: 39.35,
  spatialReference: { wkid: 4326 }
}&lt;/LI-CODE&gt;&lt;P&gt;ALSO&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const [Extent] = await $arcgis.import([
  "@arcgis/core/geometry/Extent"
]);

const mapElement = document.getElementById("myMap");

await mapElement.componentOnReady();

mapElement.extent = new Extent({
  xmin: -95.50,
  ymin: 39.15,
  xmax: -95.20,
  ymax: 39.35,
  spatialReference: { wkid: 4326 }
});&lt;/LI-CODE&gt;&lt;P&gt;goTo&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;await mapElement.goTo({
  xmin: -95.50,
  ymin: 39.15,
  xmax: -95.20,
  ymax: 39.35,
  spatialReference: { wkid: 4326 }
});&lt;/LI-CODE&gt;&lt;P&gt;OR goTo&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const view = mapElement.view;

view.goTo({
  xmin: -95.50,
  ymin: 39.15,
  xmax: -95.20,
  ymax: 39.35,
  spatialReference: { wkid: 4326 }
});&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 11 Mar 2026 14:58:55 GMT</pubDate>
    <dc:creator>MatthewDriscoll</dc:creator>
    <dc:date>2026-03-11T14:58:55Z</dc:date>
    <item>
      <title>Set initial extent on page load</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/set-initial-extent-on-page-load/m-p/1689925#M88286</link>
      <description>&lt;P&gt;Just started using API v5.&amp;nbsp; Using the arcgis-map component.&amp;nbsp; Trying to set the initial extent when the page loads through JavaScript.&amp;nbsp; I've tried so many possibilities I can't remember them all.&lt;/P&gt;&lt;P&gt;I'm using goTo(extent), however, I've tried setting the extent on the view directly and neither seems to work.&amp;nbsp; The map always zooms to the extent of one of the layers (either the base layers or the map service layer).&amp;nbsp; NOTE: I have four base layers and one "regular" layer.&lt;/P&gt;&lt;P&gt;If I try to set the extent directly on the view it seems to be ignored.&amp;nbsp; What I think is happening is, the extent is set, then, overridden by the extent of one of the layers.&lt;/P&gt;&lt;P&gt;If I try to use goTo, I get an exception telling me a goTo is already in progress.&lt;/P&gt;&lt;P&gt;I've tried waiting for various events first to no avail.&amp;nbsp; I finally just settled on a 2 second delay, then call goTo.&amp;nbsp; At that time, the previous goTo is finished.&amp;nbsp; But, I am reasonably assured that this is a bad way of doing it, and, I don't like it.&lt;/P&gt;&lt;P&gt;Is there a preferred way to set the initial extent, in JavaScript, when the page loads initially, using the arcgis-map component?&lt;/P&gt;&lt;P&gt;NOTE: The extent I need is stored in local storage, so, I can't set it on the arcgis-map component in the HTML.&amp;nbsp; I have to wait until I can run some javascript to get it out of local storage.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2026 13:23:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/set-initial-extent-on-page-load/m-p/1689925#M88286</guid>
      <dc:creator>Stuart-Harlan</dc:creator>
      <dc:date>2026-03-11T13:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: Set initial extent on page load</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/set-initial-extent-on-page-load/m-p/1689956#M88287</link>
      <description>&lt;LI-CODE lang="javascript"&gt;const mapElement = document.getElementById("yourMap");

await mapElement.componentOnReady();

mapElement.center = [-95.38, 39.23];

// Set scale at the view. 
const view = mapElement.view;
view.scale = 560000; &lt;/LI-CODE&gt;&lt;P&gt;OR&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;mapElement.extent = {
  xmin: -95.50,
  ymin: 39.15,
  xmax: -95.20,
  ymax: 39.35,
  spatialReference: { wkid: 4326 }
}&lt;/LI-CODE&gt;&lt;P&gt;ALSO&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const [Extent] = await $arcgis.import([
  "@arcgis/core/geometry/Extent"
]);

const mapElement = document.getElementById("myMap");

await mapElement.componentOnReady();

mapElement.extent = new Extent({
  xmin: -95.50,
  ymin: 39.15,
  xmax: -95.20,
  ymax: 39.35,
  spatialReference: { wkid: 4326 }
});&lt;/LI-CODE&gt;&lt;P&gt;goTo&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;await mapElement.goTo({
  xmin: -95.50,
  ymin: 39.15,
  xmax: -95.20,
  ymax: 39.35,
  spatialReference: { wkid: 4326 }
});&lt;/LI-CODE&gt;&lt;P&gt;OR goTo&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const view = mapElement.view;

view.goTo({
  xmin: -95.50,
  ymin: 39.15,
  xmax: -95.20,
  ymax: 39.35,
  spatialReference: { wkid: 4326 }
});&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 11 Mar 2026 14:58:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/set-initial-extent-on-page-load/m-p/1689956#M88287</guid>
      <dc:creator>MatthewDriscoll</dc:creator>
      <dc:date>2026-03-11T14:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: Set initial extent on page load</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/set-initial-extent-on-page-load/m-p/1690025#M88289</link>
      <description>&lt;P&gt;Thanks for the reply.&amp;nbsp; I finally figured it out.&amp;nbsp; Turns out I was calling an additional goTo AFTER calling goTo to set my initial extent, which is why the API was telling me a goTo was already in progress.&amp;nbsp; So...programmer error.&amp;nbsp; Once I figured that out, it's working fine now.&amp;nbsp; Thanks for the examples.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2026 17:28:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/set-initial-extent-on-page-load/m-p/1690025#M88289</guid>
      <dc:creator>Stuart-Harlan</dc:creator>
      <dc:date>2026-03-11T17:28:22Z</dc:date>
    </item>
  </channel>
</rss>

