<?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: setExtent() doesn't take effect in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setextent-doesn-t-take-effect/m-p/715973#M66554</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Glad to help. That's one of the perils of JavaScript; no type checking. It's a bit more work from time to time but I still prefer it to strongly typed languages. Anyway, I don't think the API should be doing type checking...it's gotta leave a little work for us :).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 May 2010 05:37:17 GMT</pubDate>
    <dc:creator>DerekSwingley</dc:creator>
    <dc:date>2010-05-13T05:37:17Z</dc:date>
    <item>
      <title>setExtent() doesn't take effect</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setextent-doesn-t-take-effect/m-p/715969#M66550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi... I'm really puzzled and blocked by this one.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Here I have code in one of the map's onLoad event handlers, where I'm attempting to set the extent of the map based on params in the URL:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;alert('setting extent according to url');
var newExtent = new esri.geometry.Extent(params.xmin, params.ymin, params.xmax, params.ymax,
map.spatialReference);
alert('new extent: ' + newExtent.xmin + ', ' + newExtent.xmax + ', ' + newExtent.ymin + ', ' + newExtent.ymax);
map.setExtent(newExtent);
var pe = map.extent;
alert('post extent: ' + pe.xmin + ', ' + pe.xmax + ', ' + pe.ymin + ', ' + pe.ymax);
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The alerts show clearly that the "post extent" (the map extent after I call setExtent()) is not the same as the "new extent" (the extent passed to setExtent()). In fact the map extent seems to be totally unaffected by my call to setExtent().&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;There are no errors thrown either, that I can tell. I'm running in Firefox with Firebug, so I should be notified if there are errors.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The same thing also occurs with IE 8.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyone have ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ArcGIS Server 9.3.1, JS API 1.5.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 May 2010 20:43:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setextent-doesn-t-take-effect/m-p/715969#M66550</guid>
      <dc:creator>LarsHuttar</dc:creator>
      <dc:date>2010-05-04T20:43:56Z</dc:date>
    </item>
    <item>
      <title>Re: setExtent() doesn't take effect</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setextent-doesn-t-take-effect/m-p/715970#M66551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Further notes... &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm calling setExtent() in a map onload event handler. So the map should already be loaded by the time I call setExtent().&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I also tried setting a timer (250 ms) from the map onload handler, and then calling setExtent() from the timer event handler. That didn't help... setExtent still has no effect.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ESRI tech support suggested I try the new 2.0 version of the JS API, instead of 1.5. So I did. No change in the behavior.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 May 2010 15:04:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setextent-doesn-t-take-effect/m-p/715970#M66551</guid>
      <dc:creator>LarsHuttar</dc:creator>
      <dc:date>2010-05-12T15:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: setExtent() doesn't take effect</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setextent-doesn-t-take-effect/m-p/715971#M66552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can you post a more complete code snippet? I can confirm that setExtent() works in 1.5. Not sure why support would tell you to go to 2.0 for this (there are plenty of other good reasons, I just don't think this is one of them :)). It's a basic function that, AFAIK, has not been broken in any version of the API.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 May 2010 15:25:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setextent-doesn-t-take-effect/m-p/715971#M66552</guid>
      <dc:creator>DerekSwingley</dc:creator>
      <dc:date>2010-05-12T15:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: setExtent() doesn't take effect</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setextent-doesn-t-take-effect/m-p/715972#M66553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Swingley, thanks for your effort to help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It turned out that the problem was that in my extent constructor,&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;new esri.geometry.Extent(params.xmin, params.ymin, params.xmax, params.ymax,
&amp;nbsp;&amp;nbsp; map.spatialReference);&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;the first four values I'm passing in are strings... (naturally enough, since they are just snipped out of the URL, as returned by esri.urlToObject(window.location.href).query).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I assumed javascript would convert them to numbers if required, or the constructor would raise an error or do the conversion itself. Unfortunately none of these is the case.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I change the constructor to explicitly convert to numbers, e.g.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;new esri.geometry.Extent(parseFloat(params.xmin), parseFloat(params.ymin), etc.);&lt;/PRE&gt;&lt;SPAN&gt; then everything works fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My request for ESRI would be that the Extent constructor either accept strings as arguments and parse them into numbers, or throw an error when passed non-numbers. That would be more robust API design. Silently creating an object that doesn't work, tends to waste a lot of developer time.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:40:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setextent-doesn-t-take-effect/m-p/715972#M66553</guid>
      <dc:creator>LarsHuttar</dc:creator>
      <dc:date>2021-12-12T06:40:09Z</dc:date>
    </item>
    <item>
      <title>Re: setExtent() doesn't take effect</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setextent-doesn-t-take-effect/m-p/715973#M66554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Glad to help. That's one of the perils of JavaScript; no type checking. It's a bit more work from time to time but I still prefer it to strongly typed languages. Anyway, I don't think the API should be doing type checking...it's gotta leave a little work for us :).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 May 2010 05:37:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setextent-doesn-t-take-effect/m-p/715973#M66554</guid>
      <dc:creator>DerekSwingley</dc:creator>
      <dc:date>2010-05-13T05:37:17Z</dc:date>
    </item>
    <item>
      <title>Re: setExtent() doesn't take effect</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setextent-doesn-t-take-effect/m-p/715974#M66555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;@huttarl &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; I am having the same issue as setExtent not working and i tried converting the string to float as you mentioned but no luck.What i am actually trying is when they click save ,it should refresh the map with same location.Please see the attached code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am also thinking of version of the script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Jan 2011 16:18:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setextent-doesn-t-take-effect/m-p/715974#M66555</guid>
      <dc:creator>VanithaV</dc:creator>
      <dc:date>2011-01-31T16:18:56Z</dc:date>
    </item>
    <item>
      <title>Re: setExtent() doesn't take effect</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setextent-doesn-t-take-effect/m-p/715975#M66556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm having a similar problem with map.setExtent().&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It will work the first time that I try it, but will refuse to set the extent after that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is how I load my features into my map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
function onResults(results) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var features = results.features;
&amp;nbsp;&amp;nbsp;&amp;nbsp; var len = features.length;
&amp;nbsp;&amp;nbsp;&amp;nbsp; annexDict = {};
&amp;nbsp;&amp;nbsp;&amp;nbsp; map.graphics.clear();
 var sel = dojo.byId("annexSelect");
&amp;nbsp;&amp;nbsp;&amp;nbsp; while (sel.hasChildNodes()) {
&amp;nbsp; sel.removeChild(sel.lastChild);
 }
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; var j = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp; for (j = 0; j &amp;lt; features.length; j++) {
&amp;nbsp; var feature = features&lt;J&gt;;
&amp;nbsp; var item = feature.attributes;
&amp;nbsp; var c = dojo.doc.createElement("option");
&amp;nbsp; c.innerHTML = "TEST: " + item.ANNEXATION;
&amp;nbsp; c.value = item.ANNEXATION;
&amp;nbsp; sel.appendChild(c);
&amp;nbsp; annexDict[c.value] = {
&amp;nbsp;&amp;nbsp; annex: item.ANNEXATION,
&amp;nbsp;&amp;nbsp; graphic: feature
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.graphics.add(feature);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
}&lt;/J&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My results get added a Multiselect list and a dictionary object.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Then when an item in the list is clicked, I handle it like this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
function onAnnexInListClicked(e) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log("option was clicked");
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (e.target) {
&amp;nbsp; try {
&amp;nbsp;&amp;nbsp; var targ = e.target;
&amp;nbsp;&amp;nbsp; console.log(targ.value);
&amp;nbsp;&amp;nbsp; var item = annexDict[targ.value];
&amp;nbsp;&amp;nbsp; console.log("from dictionary: Annexation = " + item.annex);
&amp;nbsp;&amp;nbsp; var g = item.graphic;
&amp;nbsp;&amp;nbsp; var geom = g.geometry;
&amp;nbsp;&amp;nbsp; var ext = geom.getExtent();
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; // tried to explicitly create a new extent, but same result
&amp;nbsp;&amp;nbsp; var xmin = ext.xmin;
&amp;nbsp;&amp;nbsp; var ymin = ext.ymin;
&amp;nbsp;&amp;nbsp; var xmax = ext.xmax;
&amp;nbsp;&amp;nbsp; var ymax = ext.ymax;
&amp;nbsp;&amp;nbsp; var sr = new esri.SpatialReference({wkid: 102100});

&amp;nbsp;&amp;nbsp; var gExt = new esri.geometry.Extent(xmin, ymin, xmax, ymax, sr);
&amp;nbsp;&amp;nbsp; map.setExtent(gExt);
&amp;nbsp;&amp;nbsp; // map.setExtent(ext); // this had the same result
&amp;nbsp;&amp;nbsp; console.log("map extent changed");
&amp;nbsp; } catch(err) {
&amp;nbsp;&amp;nbsp; console.log("error in setting map extent to graphic extent");
&amp;nbsp;&amp;nbsp; console.log(err);
&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The first time an item is clicked, the map will zoom to the proper location.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;After that, all subsequent requests to change the map extent seem to have no effect. My console traces show that I am clicking on a new item and no errors are being thrown, so I'm a bit stumped at this point.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be appreciated, thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:40:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setextent-doesn-t-take-effect/m-p/715975#M66556</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2021-12-12T06:40:12Z</dc:date>
    </item>
    <item>
      <title>Re: setExtent() doesn't take effect</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setextent-doesn-t-take-effect/m-p/715976#M66557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;@huttarl &lt;BR /&gt; I am having the same issue as setExtent not working and i tried converting the string to float as you mentioned but no luck.What i am actually trying is when they click save ,it should refresh the map with same location.Please see the attached code.&lt;BR /&gt;I am also thinking of version of the script.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;/BLOCKQUOTE&gt;&lt;SPAN&gt;Vani, what actually is happening when they click save? nothing?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Actually I don't see a save button in your code. Do you mean the Refresh asp:button?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Have you tried checking the values of xmin etc. after these statements:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newExtent.xmin =parseFloat(coordinate[1]);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newExtent.ymin = parseFloat(coordinate[3]);&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;e.g. using an alert, or Firebug console, or something?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm curious why you use coordinate subscripts 1,3,5,7 instead of 1,2,3,4.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:40:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setextent-doesn-t-take-effect/m-p/715976#M66557</guid>
      <dc:creator>LarsHuttar</dc:creator>
      <dc:date>2021-12-12T06:40:15Z</dc:date>
    </item>
  </channel>
</rss>

