AnsweredAssumed Answered

Web AppBuilder setextent not working

Question asked by dave_adams on Mar 7, 2016
Latest reply on Mar 7, 2016 by dave_adams

Hi,

I have created a small demo widget in the Developer version of WAB to add some graphics (a target grid). After completion of a task I want to display to zoom to the extent of the graphics however my attempts to reset the map extent map.setExtent fail. When I print out the coordinates of the map (map.extent) before and after they remain the same. The app spatial reference is reported as 102100 when I print it in the console and the app is using a standard Esri basemap.

 

var testExtent = this.map.extent;

console.log(testExtent.xmin + "," + testExtent.ymin + "," + testExtent.xmax + "," + testExtent.ymax);

console.log(this.map.spatialReference);

        

var sr = new SpatialReference(102100);

var xOrigin = targetX - 500;

var yOrigin = targetY - 500;

         

var gridExtent = new Extent(xOrigin, yOrigin, xOrigin + 1000, yOrigin + 1000, this.map.spatialReference);

console.log(gridExtent.xmin + "," + gridExtent.ymin + "," + gridExtent.xmax + "," + gridExtent.ymax);

         

this.map.setExtent = gridExtent.expand(1.5);

testExtent = this.map.extent;

console.log(testExtent.xmin + "," + testExtent.ymin + "," + testExtent.xmax + "," + testExtent.ymax);

console.log(this.map.spatialReference);

 

any help would be greatly appreciated.

Outcomes