Hey all,
Im trying to configure the Query Widget in WAB Dev Edition so that when you click on a result of the query it will zoom to the shape of the polygon. Right now it zooms to a default zoom level but it too far out and I cannot figure out where to change the code to zoom to the shape.
Ive found the following code affects the zoom level because when i comment the code out it no longer zooms. Ive tried to enter different zoomfactors into the geometry.getExtent() and extent.expand() but nothing changes.
html.addClass(tr, 'jimu-state-active');
var feature = tr.feature;
var geometry = feature.geometry;
if (geometry) {
var geoType = geometry.type;
var centerPoint, extent;
if (geoType === 'point') {
centerPoint = geometry;
} else if (geoType === 'multipoint') {
if (geometry.points.length === 1) {
centerPoint = geometry.getPoint(0);
} else if (geometry.points.length > 1) {
centerPoint = geometry.getPoint(0);
}
} else if (geoType === 'polyline') {
extent = geometry.getExtent();
extent = extent.expand(1.4);
centerPoint = extent.getCenter();
} else if (geoType === 'polygon') {
extent = geometry.getExtent();
extent = extent.expand(1.4);
centerPoint = extent.getCenter();
} else if (geoType === 'extent') {
extent = geometry;
extent = extent.expand(1.4);
centerPoint = extent.getCenter();
}
var featureSet = jimuUtils.toFeatureSet(feature);
jimuUtils.zoomToFeatureSet(this.map, featureSet);
if (typeof this.map.infoWindow.setFeatures === 'function') {
this.map.infoWindow.setFeatures([feature]);
}
Solved! Go to Solution.
Yes I am. I am testing on a basic feature service of zip codes.