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.
Solved! Go to Solution.
Dave,
The setExtent method defined this way.
this.map.setExtent(gridExtent.expand(1.5), true);
Dave,
The setExtent method defined this way.
this.map.setExtent(gridExtent.expand(1.5), true);
Many thanks Robert - I'd spent so long looking at the coordinates and spatial references I had missed the obvious error.