Setting Zoom/Extent for Query Widget Results

2784
11
Jump to solution
03-22-2019 09:19 PM
ArthurKay
New Contributor III

So I have been trying this evening to have a more "zoomed out" view when selecting results from a query. I believe I have located the relevant code in my apps folder under WebappBuilderforArcGIS>server>apps>[myapp]>widgets>Query>SingleQueryResult.js


I'm particularly looking at the polylines section of code as I am working with some Roads data atm, although learning the general method for other geometry types would be great too.


I've tried a few simple things including jacking up the extend.expand(10) which didn't seem to make a difference. I was able to break the results behavior of zooming to extent, so I think I am working on the right code block, but just unclear the best way to proceed.

Thanks in advance for any assistance!

this._selectResultTr(tr);

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();
}
0 Kudos
11 Replies
RobertScheitlin__GISP
MVP Emeritus

@RobertPiatek  Maybe you are changing the wrong file or have not cleared your browsers cache. When working with a configured application you have to change that applications widgets code.

[Install Directory]\server\apps\[App#]\widgets\Query\SingleQueryResult.js

0 Kudos
InnovaAdministrator
New Contributor II

Hi there! Do you know if this code works for the group filter widget as well? I have a group filter for multiple layers, however two of my layers fall outside the area I want to query on. When I apply the group filter and the map attempts to zoom it is confused and the map zooms way out of the area that I filtered.

Thank you in advance for any help!

Liz

0 Kudos