I am trying to step through a set of selected features, zoom to the extent of the feature, do something with it and then go to the next feature and do the same. I can't seem to trap the end of the zoom no matter what I do. Does anybody have code that does this successfully. It works fine for one. It just doesn't work when I loop through a set of features. Here's what I've tried:
printSingleParcelFeature: function (feature, callback) {
var self = this;
self.zoomSelectedOne(feature, function() {
callback();
});
},
zoomSelectedOne: function(feature, callback) {
var gExt;
var selectedExt;
//Also tried 'zoom-end'. That never works.
var mapZoomChange = this.map.on('extent-change', zoomHandler);
function zoomHandler() {
console.info("Extent Change");
setTimeout(lang.hitch(this, function () {
mapZoomChange.remove();
callback();
}), 1000);
}
gExt = feature.geometry.getExtent();
if (gExt) {
selectedExt = gExt.expand(this.zoomSelectExpand,true);
this.map.setExtent(selectedExt);
console.info("Set Extent: " + feature.attributes["PIN"]);
}
},
My console results are basically this:

I also tried this, but again the extent only changes for the last one:
zoomSelectedOne: function (feature, callback) {
var gExt;
var selectedExt;
gExt = feature.geometry.getExtent();
if (gExt) {
selectedExt = gExt.expand(this.zoomSelectExpand,true);
this.map.setExtent(selectedExt).then(callback());
}
},