When a user types an address into the Search widget in WAB which is using the Esri World Geocoder, they get results from other states in the U.S. We want to constrain the addresses that are returned to be limited to our local area, either our city, county, zip codes, or an extent rectangle. Do we need the WAB Developer Edition to do this? If so, is there a custom widget out there already that handles this? If not, any advice on how to do it is appreciated.
Solved! Go to Solution.
Sorry I was busy implementing it. It works perfectly! I have marked your answer as correct. Thanks so much for your help!!
Thanks for the help Robert, I'm trying to implement this on an app and now receiving a create widget error/Search, when trying to edit the app. Any ideas? This is with WAB 1.3
Leo,
What is the browsers web console telling you. Sounds like a syntax error or you mixed up the order of the require and their subsequent vars.
I started over and tried again, now I'm not getting the widget to appear on screen during loading. Editing the widget just causes it to spin:
Leo,
I would have to see your search widget code with the changes you made.
This is what I have so far:
Leo,
You are missing a comma after the
"type": "Locator",
"searchExtent": {
Thanks for the help, I'm getting this error now in the console when I try to type in a search:
my Widget.js code looks a bit different than the example:
Leo,
This thread was for WAB 1.2. It looks like you are using 1.3 so the code has changed.
Widget.js Require section (line 3 and 8):
'esri/lang', './utils', 'esri/geometry/Extent', 'dojo/NodeList-dom' ], function(declare, lang, array, html, when, on, aspect, query, keys, Deferred, all, BaseWidget, LayerInfos, jimuUtils, Search, Locator, FeatureLayer, InfoTemplate, esriLang, utils, Extent) { //To create a widget, you need to derive from BaseWidget.
_convertConfig function(line 14)
_convertConfig: function(config) { var sourceDefs = array.map(config.sources, lang.hitch(this, function(source) { var def = new Deferred(); if (source && source.url && source.type === 'locator') { def.resolve({ locator: new Locator(source.url || ""), outFields: ["*"], singleLineFieldName: source.singleLineFieldName || "", name: jimuUtils.stripHTML(source.name || ""), placeholder: jimuUtils.stripHTML(source.placeholder || ""), countryCode: source.countryCode || "", maxResults: source.maxResults || 6, useMapExtent: !!source.searchInCurrentMapExtent, searchExtent: (source.searchExtent) ? new Extent(source.searchExtent) : null }); } else if (source && source.url && source.type === 'query') {
config_Search.json (the same as before).