AnsweredAssumed Answered

Zoom to selected II

Question asked by Grieck on Apr 21, 2017
Latest reply on Apr 22, 2017 by ajbooter

Hello, I'm using WAB 2.2 and the Jewelry Box Theme.

 

I'm trying to select a feature on the map and zoom to it. I would think there would be examples of this but they sure are hard to find.

 

queryTask = new QueryTask(MyFeatureLayer);
query = new Query();
query.where = myWhereClause;
query.returnGeometry = true;
query.outSpatialReference = this.map.spatialReference;
queryTask.execute(query, function (results) {
   var geo = results.features[0].geometry;
   this.map.setExtent(geo.getExtent(),true);
});

I'm attempting to select a single point in a point feature layer and zoom to that feature.

 

TypeError: Cannot read property 'toJson' of null
at Object.setExtent (init.js:593)

Outcomes