Select to view content in your preferred language

Configure search widget

3395
6
04-08-2016 12:52 PM
deleted-user-OlpHy1NoMNug
Deactivated User

For some reason I'm not able to configure the Zoom Scale on the search widget using the following feature layer:

Layer: Market Vendors (ID: 0)

The other layers in that same map service work but for some reason this one won't.  The box for Zoom Scale just isn't available.  Am I missing something?

Scott

Tags (1)
6 Replies
RobertScheitlin__GISP
MVP Emeritus

Scott,

  ZoomScale is only available for those layer that do not return a extent like points. As your layer is a polygon the zoomScale would not be used thus the option is not available.

deleted-user-OlpHy1NoMNug
Deactivated User

Can I change the zoom in the code?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Scott,

  Sure,  in the [install dir]\server\apps\[app#]\widgets\Search\Widgets.js file

find the _convertConfig function and add this code (line 13 - 15):

              var convertedSource = {
                featureLayer: flayer,
                outFields: ["*"],
                searchFields: fNames,
                displayField: source.displayField || "",
                exactMatch: !!source.exactMatch,
                name: jimuUtils.stripHTML(source.name || ""),
                placeholder: jimuUtils.stripHTML(source.placeholder || ""),
                maxResults: source.maxResults || 6,
                infoTemplate: template,
                useMapExtent: !!source.searchInCurrentMapExtent
              };
              if(flayer.name === "Your layer name"){
                convertedSource.autoNavigate = false;
              }

The find the _onSelectResult  function and add these lines to the end of the function:

          if(result.name === "your configured search layer name"){
            this.map.setExtent(result.feature.geometry.getExtent().expand(1.2));
          }
JDBurroughs1
Occasional Contributor

This was very helpful! Thanks Robert.

Here's a similar modification. Add the following to the Widget.js file at the end of the _onSelectResult function (approx line 716 of the code).

this.map.setExtent(result.extent.expand(3));

0 Kudos
AlexSanders
Frequent Contributor

JD, 

Thank you for your addition to this thread and adding that code snippet worked perfectly to zoom to the extent of the polygon and zooms out one LOD level. However after updating to the latest build of the WAB, I noticed a bug that is coming up in my application. 

The user enters a search parameter and it zooms to selected feature. If a user then enters another parameter in the search box and selects the selected feature, the application will zoom to the feature but the map then becomes a solid grey background and won't display any of the services or basemap. You can then zoom in or out and the feature will then appear as well as the basemap. Is there any additional code that can be added to clear the previous extent or whatever is hanging up the map?

First Search Result 

Second Search Result

Thank you 

Alex

0 Kudos
JDBurroughs1
Occasional Contributor

I'm not able to replicate your issue. Are you still getting this result? If so, what version of WAB are you on?

0 Kudos