Social Media App and Geocoding Service

2980
10
Jump to solution
03-13-2014 12:35 PM
mpboyle
Occasional Contributor III
I have downloaded the social media web app template and am wondering why when I plug in our own geocode service the entire search box disappears?

There is a place within the commonConfig.js file to enter a URL for a geocode service, however when I enter ours, the search box disappears.

Any ideas would be greatly appreciated!
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
IanWittenmyer
Esri Contributor
You have a couple of options based on the way the app was written. 

Option 1) configure the app to use multiple locators with the Esri world geocoder listed first within the commonConfig.js file, this will enable autoComplete for both locators, but your end user will have to switch to the composite in the dropdown menu in the app.

geocode: [{  url: location.protocol + "//geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"},          {          url: location.protocol + "//gis.linncounty.org/arcgis/rest/services/PublicBase/LocatorComposite/GeocodeServer",    name: "LocatorComposite",    singleLineFieldName: "SingleLine",    placefinding: true,    placeholder: "Find an Address or GPN"                 }]


Option 2: change the code to set autoComplete: true

Back in the js\modules\utils.js file again around line 83 you could change the options of the geocoder to look something like this:

            var options = {                 map: _self.options.map,   zoomScale: 400,                 theme: 'modernGrey',                 autoComplete:true             };

View solution in original post

0 Kudos
10 Replies
IanWittenmyer
Esri Contributor

There is a place within the commonConfig.js file to enter a URL for a geocode service, however when I enter ours, the search box disappears.



Try defining the singleLineFieldName and setting placefinding to true as in this example.

[ATTACH=CONFIG]32221[/ATTACH]
0 Kudos
mpboyle
Occasional Contributor III
Thanks for the reply Ian.  I have made the additions to the commonConfig.js file and the search box now appears, however I'm getting an error when searching for addresses that are within our locator.  Attached is what I have input into the commonConfig.js file.

Do I need to replace any values I currently have?

Thanks again!
0 Kudos
IanWittenmyer
Esri Contributor
Do I need to replace any values I currently have?


Hi Matt, the singleLineFieldName should match the value your geocode server is expecting. 
On your server the value is 'Single Line Input'. So in your code it should look like this:

singleLineFieldName: "Single Line Input",


Are you located in Cedar Rapids?  I worked in the great america building for 6 years.
0 Kudos
mpboyle
Occasional Contributor III
Thanks a lot Ian!  Geocoder works like expected now.

Would you happen to know how to set the zoom level when an address is selected?

And yes, I am located in Cedar Rapids, working for Linn County.  It's a small world!
0 Kudos
IanWittenmyer
Esri Contributor
Thanks a lot Ian!  Geocoder works like expected now.

Would you happen to know how to set the zoom level when an address is selected?

And yes, I am located in Cedar Rapids, working for Linn County.  It's a small world!



Cool, i had a fun time in Cedar Rapids. To set the zoom level you can try adding this to zoomScale: 400, to the js\modules\utils.js around line 83.

here is some additional info on it. https://developers.arcgis.com/javascript/jsapi/geocoder.html#zoomscale
0 Kudos
mpboyle
Occasional Contributor III
I've created a composite locator and am wondering if that can be used...?  Below is what I in the geocode parameter of the commonConfig file:

geocode: [{
            url: location.protocol + "http://gis.linncounty.org/arcgis/rest/services/PublicBase/LocatorComposite/GeocodeServer",
     name: "LocatorComposite",
     singleLineFieldName: "Single Line Input",
     placefinding: true,
     placeholder: "Find an Address or GPN"
            }]


It doesn't seem to be working so I'm wondering what part of the code is wrong or if a composite locator can be used?
0 Kudos
IanWittenmyer
Esri Contributor
Yes, you can use a composite locator with the templates.  In your code, the URL and the singleLineFieldName need to be changed. The singleLineFieldName can be determined by checking the 'Single Line Address Field' value of a geocode server, in this case it was "SingleLine".

geocode: [{
            url: location.protocol + "//gis.linncounty.org/arcgis/rest/services/PublicBase/LocatorComposite/GeocodeServer",
     name: "LocatorComposite",
     singleLineFieldName: "SingleLine",
     placefinding: true,
     placeholder: "Find an Address or GPN"
            }]
0 Kudos
mpboyle
Occasional Contributor III
Thanks again Ian!

My last question (hopefully!)...is there a way to have the app autofill options as you start typing in text?  This happens in the web map on ArcGIS Online.  I think it's very useful for the end user and I'd like to have this ability in the app as well.

Thanks as always!

[ATTACH=CONFIG]32731[/ATTACH]
0 Kudos
IanWittenmyer
Esri Contributor
You have a couple of options based on the way the app was written. 

Option 1) configure the app to use multiple locators with the Esri world geocoder listed first within the commonConfig.js file, this will enable autoComplete for both locators, but your end user will have to switch to the composite in the dropdown menu in the app.

geocode: [{  url: location.protocol + "//geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"},          {          url: location.protocol + "//gis.linncounty.org/arcgis/rest/services/PublicBase/LocatorComposite/GeocodeServer",    name: "LocatorComposite",    singleLineFieldName: "SingleLine",    placefinding: true,    placeholder: "Find an Address or GPN"                 }]


Option 2: change the code to set autoComplete: true

Back in the js\modules\utils.js file again around line 83 you could change the options of the geocoder to look something like this:

            var options = {                 map: _self.options.map,   zoomScale: 400,                 theme: 'modernGrey',                 autoComplete:true             };
0 Kudos