Select to view content in your preferred language

Customize information lookup template

6219
14
02-10-2015 11:49 AM
KendellRyan
Frequent Contributor

I have been using the Information look up template (hosted). I now have a need to change the geocoder for the app and have it different than the geocoder we default to in our AGOLO site.  I downloaded the files for the lookup template from github.  I have it working locally with my map, However I cannot seem to get it to pick up on my geocoder.  I tried changing the URL in the commonConfig.js and/or in the default.js (the section with helper services).  However there is something else going on beyond there that I am missing.  I'd appreciate any suggestions. I am a novice with javascript but I've gotten some of the other templates customized and working.

0 Kudos
14 Replies
KellyHutchins
Esri Frequent Contributor

Can you zip up your customized version of the app and attach it to this thread? This might help us see what's going wrong.

0 Kudos
KendellRyan
Frequent Contributor

Sure. Can I email the zipped folder to you?

0 Kudos
KellyHutchins
Esri Frequent Contributor

Sure send it to khutchins@esri.com

0 Kudos
MikeMillerGIS
Esri Frequent Contributor

Kendell,

   The app uses the settings in your ArcGIS Online to get a list of locators.  If you do not want to add your locator to the org and have the app only use one locator, you can change the _getGeocoders function in the search.js javascript function.  You will want to only return your locator in the defaultSources variable.

Basically you want the function to do this:

geocoder.locator = new Locator(<YourURL);

defaultSources.push(geocoder);

geocoder.placeholder = this.i18n.geocoder.defaultText;

Edit:  The above is untested

0 Kudos
KendellRyan
Frequent Contributor

Yes, we want a different locator for this app than the ones we have set in our AGOLO site.  That makes sense that it's reverting to our organizational settings, but unfortunate that it's not a simple change (for a non js programmer).

I just made those changes in the search.js but am still getting the same result.  I'll keep hacking at it.  I take it that I don't need to change anything in the default.js or common.js where there are references to the geocoder?

0 Kudos
NicholasGross
Deactivated User

I've worked on this all morning and unfortunately haven't accomplished a thing. The helper services in the default.js and the commonConfig.js don't seem to do anything at all in this template. The config settings have to be changed in the templateOptions.js file instead. But, when setting queryForOrg: false in templateOptions, the app ignores your organization completely, meaning no basemap gallery, just an error that it can't find any basemaps.

I can't imagine that this is the intended behavior for this setting considering there is no explicit place in the helper services to setup a different basemap gallery, and also because this is not the behavior of other apps, like the basic viewer. The basic viewer app allows the queryForOrg setting to be false in the commonConfig.js file so that it will make use of the custom helper services but still retrieves basemap information from your organization.

Also, I was unable to get Michael Miller's suggestion working. No matter how many places I explicitly set the locator to my url, it ultimately uses the default Esri world geocoding service.

0 Kudos
MikeMillerGIS
Esri Frequent Contributor

I checked in changes tonight that fix the issue you are having.  You can now set queryToOrg to false and it will load the basemap gallery.  You will need to specify your geocoders, the url and singleLineFieldName are required.

Esri/information-lookup · GitHub

NicholasGross
Deactivated User

Thanks Michael, my geocoder and basemap gallery are working now. Unfortunately, and this may only be affecting me, the geocoder exhibits some odd behavior when offering suggestions with my custom locator.

On the first use after each page refresh, the suggestion dropdown list requires a double-click to select an address. After the first use, it requires a single click. A small issue, but since the address bar is the primary way for users to interact with this particular app, I think it might be confusing since it appears to be a single click menu. I wonder if someone could confirm this behavior?

0 Kudos
MikeMillerGIS
Esri Frequent Contributor

I cannot repo this.  It could be something specific with your locator.  Can you compare your settings in your locator to mine?

Locators/WaterLocator (GeocodeServer)

0 Kudos