Select to view content in your preferred language

zone aliases for locator widget results?

2518
12
Jump to solution
07-24-2013 11:48 AM
BenAller
Deactivated User
We're using a local geocode service with municipal codes as the zones instead of zip codes.    It would be helpful for our end-users to see the zone names (aka municipal names) in the results tab instead of the zone numbers.  So for example, a locator result of "601 Westtown Rd, 52" would show up as "601 Westtown Rd, West Goshen Township". Is there a way to configure a list of aliases?  Perhaps within the mxml?

Thanks,
Ben
Tags (2)
0 Kudos
12 Replies
RobertScheitlin__GISP
MVP Emeritus
Ben,

   I just tested the code with my locator and replaced my ", 36201" in the results with "West Goshen Township"

Original returned match:

1702 Noble St, Anniston, AL, 36201

modified result:

1702 Noble St, West Goshen Township

                            locateResult.title = addrCandidate.address ? replaceMuniCodes(String(addrCandidate.address)) : widgetTitle;                             function replaceMuniCodes(addStr:String):String                             {                                 var retVal:String = addStr;                                 var muniCodeArr:Array = addStr.split(", ");                                 if(muniCodeArr.length == 4){                                     retVal = muniCodeArr[0] + ", ";                                     switch(muniCodeArr[3])                                     {                                         case "36201":                                         {                                             retVal += "West Goshen Township";                                             break;                                         };                                         case "36203":                                         {                                             retVal += "East Goshen Township";                                             break;                                         };                                     }                                 }                                 return retVal;                             }

Try placing a break point in the replaceMuniCodes function and step through the code hovering you mouse over variable to see their values.
0 Kudos
Juan_CarlosFranco
Esri Contributor
Anthony

   It is just checking if addrCandidate.address is null or not


Adding to Robert's reply, since address is a String the condition will evaluate to false if it is null or an empty string and true otherwise (see AS3 Type Conversions).
0 Kudos
BenAller
Deactivated User
Got it!  Just had the wrong array item.  Now reads: switch(muniCodeArr[1]).  Robert, thanks a bunch.  Really appreciate the help!

Ben
0 Kudos