Web AppBuilder setextent not working

2251
2
Jump to solution
03-07-2016 05:25 AM
DaveAdams
New Contributor III

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.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Dave,

  The setExtent method defined this way.

this.map.setExtent(gridExtent.expand(1.5), true);

Map | API Reference | ArcGIS API for JavaScript | setExtent

View solution in original post

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus

Dave,

  The setExtent method defined this way.

this.map.setExtent(gridExtent.expand(1.5), true);

Map | API Reference | ArcGIS API for JavaScript | setExtent

0 Kudos
DaveAdams
New Contributor III

Many thanks Robert - I'd spent so long looking at the coordinates and spatial references I had missed the obvious error.

0 Kudos