Filter widget: zoom to features

3668
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
JeremyDunn1
New Contributor

Good Morning Robert,

I have tried to update the Filter Widget to apply a zoom function with little success here is my Filter Widget.js file.

Which should be edited as you have shown, however it does not zoom to the location when the filter is applied. I too am running this in portal 10.5

Is this the only file that needs to be updated ? 

If you remove the filter and then re-apply it the Filter widget folder is removed and the original re-written without the edit, why is this the case ? 

Look forward to your reply,

Regards, 

Jeremy. 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jeremy,

  You missed the other additions at the start of the widget:

function(declare, array, html, lang, query, on,
 _WidgetsInTemplateMixin,
 BaseWidget, FilterUtils, FilterParameters, LayerInfos, FilterManager,
 esriRequest, QueryTask, Query, graphicsUtils) { //Added , QueryTask, Query, graphicsUtils

The reason the widget.js is replaced when you remove and re-add it is the whole concept of WAB is the stemApp is what is cloned to a new apps folders when a new add is made and when widgets are added the widget is cloned from the stemApps widget folder. So you are making changes in the apps widgets folder which is correct, but if you want those changes to be cloned into new apps then you have to also add your changes to the stemApp.

JeremyDunn1
New Contributor

Good Morning Robert,

Thank you for the reply. I think that did the trick. Although I'm wondering where the zoom function can be changed to zoom in as well as over to the point of interest. But it is moving the map to center the point I am filtering on the map. 

So where can I change the code to zoom inward. 

Regards. 

Jeremy

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jeremy,

  The provided code zooms to the extent of the filtered results. If you need to zoom in more then you would have to adjust the extent using Extent.expand method but that may mean all of your features will not be inside the extent.

0 Kudos
JeremyDunn1
New Contributor

Hi Robert,

Thanks again for the reply. Ok I'll look into this. I'm using points at the lowest zoom level so all I get is the map moving so the filtered point is in the center of the base map at the lowest zoom level.

I still don't quite understand why this functionality is not built into the Filter widget as standard.

Anyway thank you for the help. Very useful. 

Regards 

Jeremy. 

0 Kudos