Select to view content in your preferred language

Extent loads but levels out

1252
6
Jump to solution
05-16-2013 12:08 AM
Jan-WillemBaart
Emerging Contributor
I have created a map which loads an initialization extent which will be updated by a custom extent via a javascript function, loadMapFromURL(). This function extracts the extent parameters from the URL and sets this extent(thus a user is able to link to a specific view on the map).
This all works just fine on the development environment but in the test environment the level of the map is set back 2 to 4 levels. But by zooming in, the custom extent will exactly show up...

Via the console I'm able to check that the initialization extent is loaded, loadMapURL() is called which does load the custom extent and thereafter a 'new' extent is loaded.
I have been debugging and logging this issue for a while now but I can't figure out what triggers this extent change. Anyone seen this before or has a clue what's happening?
0 Kudos
1 Solution

Accepted Solutions
VinayBansal
Frequent Contributor
Try by calling the loadMapFromURL function after your map loads. So that the extents get set after the map loads

dojo.connect(map, "onLoad", function () {          loadMapFromURL();     });

View solution in original post

0 Kudos
6 Replies
VinayBansal
Frequent Contributor
Have you verified the test environment URL and development environment URL from same machine?.
Custom extent scale change if you are checking the extents in different machine with different screen resolutions. It may be setting the same extent in map, but depending upon the height and width of the map, scale changes.
0 Kudos
Jan-WillemBaart
Emerging Contributor
No, the behaviour is visible on two different machines. The map is loaded in a div with set width and height. So I suppose auto scale isn't the cause
0 Kudos
VinayBansal
Frequent Contributor
Can you post your code on how are you setting the extent?
0 Kudos
Jan-WillemBaart
Emerging Contributor
Sure!

Initialization of the map
 
if (WEBGIS_INIT_EXTENT) {
 map = new esri.Map(WEBGIS_KAART_DIV, {extent: WEBGIS_INIT_EXTENT, logo: false, fitExtent: true, slider: true});
 } else {
 map = new esri.Map(WEBGIS_KAART_DIV, { logo: true, nav:true });
 }


Setting a new extent with parameters in the URL(?xmin=32423.233 etc)
function loadMapfromURL() {
 var paramxmin = getURLParam('xmin');
 var paramymin = getURLParam('ymin');
 var paramxmax = getURLParam('xmax');
 var paramymax = getURLParam('ymax');
 var paramwkid = getURLParam('wkid');

 // check if param available
 if (paramxmin != '' && paramymin != '' && paramxmax != '' && paramymax != '' && paramwkid != '') {
  var xmin = Number(paramxmin);
  var ymin = Number(paramymin);
  var xmax = Number(paramxmax);
  var ymax = Number(paramymax);
  var wkid = Number(paramwkid);

  // Set view
  var newExtent = new esri.geometry.Extent(xmin, ymin, xmax, ymax, new esri.SpatialReference({'wkid': wkid}));
  map.setExtent(newExtent, false);
 }
}


And the call to the above functions.
dojo.ready(function() {
 webgisInitViewer();
 loadMapfromURL();
}


This is a stripped version of the code with just the setting of extents. More detail or context is possible! Hope it helps
0 Kudos
VinayBansal
Frequent Contributor
Try by calling the loadMapFromURL function after your map loads. So that the extents get set after the map loads

dojo.connect(map, "onLoad", function () {          loadMapFromURL();     });
0 Kudos
Jan-WillemBaart
Emerging Contributor
Cool, that did it! Thanks for the tip! Simple but effective 🙂
0 Kudos