AnsweredAssumed Answered

Pass Extent in URL

Question asked by xylochic627 on Jan 28, 2016
Latest reply on Mar 3, 2016 by xylochic627

In my current Flex map, I am able to pass an extent through the URL quite easily. I'm trying to update the map to JavaScript, but I'm having problems getting that same capability to work now.

 

I am currently getting an error stating, "xmin is not defined". I'm sure I've missed something simple.

 

Here's my code:

 

var urlObject = esri.urlToObject(window.location.href);     if (urlObject.query)     {     if (urlObject.query.XMin)     { xmin = urlObject.query.XMin; }     if (urlObject.query.XMax)     { xmax = urlObject.query.XMax; } if (urlObject.query.YMin) { ymin = urlObject.query.YMin; } if (urlObject.query.YMax) { ymin = urlObject.query.YMax; } var spatialRef = new SpatialReference({wkid:102100});  //set your wkid here   var urlPassedExtent = new Extent();   urlPassedExtent.xmin = xmin;   urlPassedExtent.ymin = ymin;   urlPassedExtent.xmax = xmax;   urlPassedExtent.ymax = ymax;   urlPassedExtent.spatialReference = spatialRef;   mapMain.setExtent(urlPassedExtent);   //If extent not found in URL, use initial extent   }else  {    mapMain.setExtent(extentInitial);   }

Outcomes