Search Widget sends incorrect query string (4.8 js api)

553
2
Jump to solution
09-04-2018 11:56 AM
PhilLarkin1
Occasional Contributor III

When using the Search Widget with a local geocoding service an incorrect query string is sent if the singleLineFieldName is not defined. "Single Line Input" is sent while "SingleLine" is the correct parameter name.

Example of poorly formed geocode request:  .../arcgis/rest/services/Locators/AddrComposite/GeocodeServer/findAddressCandidates?Single%20Line%20Input=808%20W%20Spokane%20Falls%20Blvd%2C%20Spokane%2C%20WA&f=json&outSR=%7B%22latestWkid%22%3A3857%2C%22wkid%22%3A102100%7D&magicKey=GST7YMc0AM9UOsEmObpaISTUYbTA1hp0&maxLocations=6

Property Defined:

sources = [{
    locator: new Locator({ url: "https://gis.spokanecounty.org/arcgis/rest/services/Locators/AddrComposite/GeocodeServer" }),
    name: "AddrComposite",
    placeholder: "search addresses",
    singleLineFieldName: "SingleLine",  //Property Defined 
}];

Example of correct request after property is defined:

.../arcgis/rest/services/Locators/AddrComposite/GeocodeServer/findAddressCandidates?SingleLine=808%20W%20Spokane%20Falls%20Blvd%2C%20Spokane%2C%20WA&f=json&outSR=%7B%22latestWkid%22%3A3857%2C%22wkid%22%3A102100%7D&magicKey=GST7YMc0AM9UOsEmObpaISTUYbTA1hp0&maxLocations=6

0 Kudos
1 Solution

Accepted Solutions
KellyHutchins
Esri Frequent Contributor

Hi Phil,

The default value for the single line field name is Single Line Input. If your service uses a different value you'll need to specify it using singleLineFieldName. Here's an FAQ  explaining when the field name will be SingeLine vs Single Line Input. 

FAQ: How does the singleLineAddress property for geocoding services vary across address locator type... 

View solution in original post

2 Replies
KellyHutchins
Esri Frequent Contributor

Hi Phil,

The default value for the single line field name is Single Line Input. If your service uses a different value you'll need to specify it using singleLineFieldName. Here's an FAQ  explaining when the field name will be SingeLine vs Single Line Input. 

FAQ: How does the singleLineAddress property for geocoding services vary across address locator type... 

PhilLarkin1
Occasional Contributor III

Hi Kelly-

Thanks for your reply. The article is very informative. I didn't realize the singleLine parameter can have different names. 

The singleLineFieldName parameter, which is the field name of the Single Line Address property in the REST services directory for the locator service, is required when configuring the Search widget to consume a geocode service.

...

The singleLineAddressField value for address locators built using the US Address locator style is Single Line Input, whereas composite locators use SingleLine.