Filter widget: zoom to features

3533
24
Jump to solution
10-13-2016 08:36 AM
helenchu
Occasional Contributor II

Can I have the filter widget zoom to features ?   Thanks.

0 Kudos
24 Replies
helenchu
Occasional Contributor II

Oh that 218 (points) was for the point feature polygon (my real app will have to use it)  .  The one I sent you returns only 1 polygon at a time.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

OK,

   But the url you proved was altered so I can not test using your data and as I mentioned with my polygon data it works fine.

0 Kudos
helenchu
Occasional Contributor II

My server is not accessible from outside.   I use portal not Arcgis online.  I notice there're some differences from the two. Thanks.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Helen,

  My last reply should fix the issue.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Helen,

   OK so I found the difference between your data and mine that I was testing. Mine was using wkid 102100 like the maps wkid.

So make this change (line 6):

//Add RJS Now zoom to the results
      var qt = QueryTask(layerInfo.getUrl());
      var q = Query();
      q.returnGeometry = true;
      q.where = layerFilterExpr;
      q.outSpatialReference = this.map.spatialReference;
      qt.execute(q, lang.hitch(this, function(fs){
          this.map.setExtent(graphicsUtils.graphicsExtent(fs.features), true);
      }));
//End RJS‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
helenchu
Occasional Contributor II

That's what it is.  Thank you so much!

0 Kudos
DavidTreering2
New Contributor III

The code changed slightly and the query is Null in the queryTask, causing it to fail, so then map.setExtent has no feature. Any ideas?

0 Kudos
MelissaPrindiville
New Contributor III

Hi Robert, I am trying to apply this same functionality using web app builder filter widget.  I added your code above but I'm not getting any results.  

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Melissa,

   You are going to have a REALLY hard time adding this code to a minified version of the widget.js like you are attempting to do.