For some reason I'm not able to configure the Zoom Scale on the search widget using the following feature layer:
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
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.
Can I change the zoom in the code?
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)); }
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));
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
I'm not able to replicate your issue. Are you still getting this result? If so, what version of WAB are you on?