<?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 map Extent issue in dojox/app/view when switching between views in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-extent-issue-in-dojox-app-view-when-switching/m-p/713046#M66255</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I’m using dojox/app/views in my application.&amp;nbsp; One of my views contains a map.&amp;nbsp; The underlying problem that I’m having is that my map is getting an invalid extent set if the user transitions quickly between views.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I’ve already turned off auto-resizing, and have implemented my own custom function that makes sure that the dijit.layout.ContentPane that&lt;BR /&gt;contains my map is visible.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried to add in logic to retain the last valid extent of the map, and reset it if it’s going to be set to NAN or Infinity, etc.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

dojo.connect(map, 'onLoad', function(theMap) {
dojo.config.lastValidExtent = theMap.extent; // Save valid extent.


dojo.connect(dijit.byId('map'), 'resize', function() { // where “map” is the dijit.layout.ContentPane that contains my map
 
 clearTimeout(resizeTimer);
 resizeTimer = setTimeout( function() {


&amp;nbsp; var node = dijit.byId("map-view").domNode.parentNode; //Checking to see if the map view is visible.
&amp;nbsp; if(node.classList.contains("dijitVisible")){
&amp;nbsp;&amp;nbsp; /*
&amp;nbsp;&amp;nbsp; Checking for an "Invalid Extent" 
&amp;nbsp;&amp;nbsp; */
&amp;nbsp;&amp;nbsp; if(isNaN(map.extent.xmax) || isNaN(map.extent.xmin) || isNaN(map.extent.ymax) || isNaN(map.extent.ymin)
&amp;nbsp;&amp;nbsp;&amp;nbsp; || map.extent.xmax == map.extent.xmin || map.extent.ymax == map.extent.ymin
&amp;nbsp;&amp;nbsp;&amp;nbsp; || map.extent.xmax == Number.POSITIVE_INFINITY || map.extent.xmax == Number.NEGATIVE_INFINITY 
&amp;nbsp;&amp;nbsp;&amp;nbsp; || map.extent.xmin == Number.POSITIVE_INFINITY || map.extent.xmin == Number.NEGATIVE_INFINITY 
&amp;nbsp;&amp;nbsp;&amp;nbsp; || map.extent.ymax == Number.POSITIVE_INFINITY || map.extent.ymax == Number.NEGATIVE_INFINITY 
&amp;nbsp;&amp;nbsp;&amp;nbsp; || map.extent.ymin == Number.POSITIVE_INFINITY || map.extent.ymin == Number.NEGATIVE_INFINITY){
&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log('INVALID EXTENT!');


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; map.setExtent(dojo.config.lastValidExtent); // Extent is "invalid" so set the extent to the last valid extent
&amp;nbsp;&amp;nbsp;&amp;nbsp; map.reposition();
&amp;nbsp;&amp;nbsp;&amp;nbsp; map.resize();
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; else{
&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.config.lastValidExtent = map.extent; // Update with new valid extent
&amp;nbsp;&amp;nbsp;&amp;nbsp; map.reposition();
&amp;nbsp;&amp;nbsp;&amp;nbsp; map.resize();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; }


 }, 500);
});
});

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What it looks like is happening now is that the Extent is not getting updated with value I have saved in the lastValidExtent variable.&amp;nbsp; I added a function for the map’s “extent-change” event and it’s getting fired after I call map.setExtent, but when I check the extent of the map inside of this function, it does not have the updated values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any way to pre-emptively check and see what the map extent is going to become and then “Cancel” it if it’s going to fall into one of the options above?&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any way to “disable” a map when leaving the map view (so it doesn’t change the extent, or resize), then re-enable it afterwards?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone have experience working with the map inside of dojo views who has had a similar issue and can offer some guidance on how the resolved it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I’ve spent quite a few days on this issue already and have pretty much come to a dead end in fixing this. &lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ANY suggestions at this point would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for your time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 06:32:43 GMT</pubDate>
    <dc:creator>TheresaRepta</dc:creator>
    <dc:date>2021-12-12T06:32:43Z</dc:date>
    <item>
      <title>map Extent issue in dojox/app/view when switching between views</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-extent-issue-in-dojox-app-view-when-switching/m-p/713046#M66255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I’m using dojox/app/views in my application.&amp;nbsp; One of my views contains a map.&amp;nbsp; The underlying problem that I’m having is that my map is getting an invalid extent set if the user transitions quickly between views.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I’ve already turned off auto-resizing, and have implemented my own custom function that makes sure that the dijit.layout.ContentPane that&lt;BR /&gt;contains my map is visible.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried to add in logic to retain the last valid extent of the map, and reset it if it’s going to be set to NAN or Infinity, etc.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

dojo.connect(map, 'onLoad', function(theMap) {
dojo.config.lastValidExtent = theMap.extent; // Save valid extent.


dojo.connect(dijit.byId('map'), 'resize', function() { // where “map” is the dijit.layout.ContentPane that contains my map
 
 clearTimeout(resizeTimer);
 resizeTimer = setTimeout( function() {


&amp;nbsp; var node = dijit.byId("map-view").domNode.parentNode; //Checking to see if the map view is visible.
&amp;nbsp; if(node.classList.contains("dijitVisible")){
&amp;nbsp;&amp;nbsp; /*
&amp;nbsp;&amp;nbsp; Checking for an "Invalid Extent" 
&amp;nbsp;&amp;nbsp; */
&amp;nbsp;&amp;nbsp; if(isNaN(map.extent.xmax) || isNaN(map.extent.xmin) || isNaN(map.extent.ymax) || isNaN(map.extent.ymin)
&amp;nbsp;&amp;nbsp;&amp;nbsp; || map.extent.xmax == map.extent.xmin || map.extent.ymax == map.extent.ymin
&amp;nbsp;&amp;nbsp;&amp;nbsp; || map.extent.xmax == Number.POSITIVE_INFINITY || map.extent.xmax == Number.NEGATIVE_INFINITY 
&amp;nbsp;&amp;nbsp;&amp;nbsp; || map.extent.xmin == Number.POSITIVE_INFINITY || map.extent.xmin == Number.NEGATIVE_INFINITY 
&amp;nbsp;&amp;nbsp;&amp;nbsp; || map.extent.ymax == Number.POSITIVE_INFINITY || map.extent.ymax == Number.NEGATIVE_INFINITY 
&amp;nbsp;&amp;nbsp;&amp;nbsp; || map.extent.ymin == Number.POSITIVE_INFINITY || map.extent.ymin == Number.NEGATIVE_INFINITY){
&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log('INVALID EXTENT!');


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; map.setExtent(dojo.config.lastValidExtent); // Extent is "invalid" so set the extent to the last valid extent
&amp;nbsp;&amp;nbsp;&amp;nbsp; map.reposition();
&amp;nbsp;&amp;nbsp;&amp;nbsp; map.resize();
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; else{
&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.config.lastValidExtent = map.extent; // Update with new valid extent
&amp;nbsp;&amp;nbsp;&amp;nbsp; map.reposition();
&amp;nbsp;&amp;nbsp;&amp;nbsp; map.resize();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; }


 }, 500);
});
});

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What it looks like is happening now is that the Extent is not getting updated with value I have saved in the lastValidExtent variable.&amp;nbsp; I added a function for the map’s “extent-change” event and it’s getting fired after I call map.setExtent, but when I check the extent of the map inside of this function, it does not have the updated values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any way to pre-emptively check and see what the map extent is going to become and then “Cancel” it if it’s going to fall into one of the options above?&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any way to “disable” a map when leaving the map view (so it doesn’t change the extent, or resize), then re-enable it afterwards?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone have experience working with the map inside of dojo views who has had a similar issue and can offer some guidance on how the resolved it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I’ve spent quite a few days on this issue already and have pretty much come to a dead end in fixing this. &lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ANY suggestions at this point would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for your time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:32:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-extent-issue-in-dojox-app-view-when-switching/m-p/713046#M66255</guid>
      <dc:creator>TheresaRepta</dc:creator>
      <dc:date>2021-12-12T06:32:43Z</dc:date>
    </item>
  </channel>
</rss>

