zone aliases for locator widget results?

2176
12
Jump to solution
07-24-2013 11:48 AM
BenAller
New Contributor III
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
1 Solution

Accepted Solutions
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.

View solution in original post

0 Kudos
12 Replies
RobertScheitlin__GISP
MVP Emeritus
Ben,

   Sure in the LocateWidget.mxml find the createLocateResults function and add some logic to replace the ", 52" with the text you are looking for.

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 == 2){
                                    retVal = muniCodeArr[0] + ", ";
                                    switch(muniCodeArr[0])
                                    {
                                        case "52":
                                        {
                                            retVal += "West Goshen Township";
                                            break;
                                        };
                                        case "53":
                                        {
                                            retVal += "East Goshen Township";
                                            break;
                                        };
                                    }
                                }
                                return retVal;
                            }
0 Kudos
BenAller
New Contributor III
Robert, 

Thanks for the detailed response.  I added the code you shared and I think I'm close but I'm hitting a snag somewhere.  The locator still functions, though it's still displaying the municipal code.  When I put a breakpoint at  function replaceMuniCodes(addStr:String):String, the String returns something like "String = Object(@52b7a1)".  Not sure if that's where the issue is, but I was thinking it would show something like "String = 601 Westtown Rd, 52".  Also, when I step through, I get a "Source not found" related to the get address class (com.esri.ags.tasks.supportClasses::AddressCandidate/get address).  Could that be the culprit?  I'm somewhat new to working in this environment, so not really sure how to resolve.  Any suggestions would be greatly appreciated. 

Thanks again. 
Ben
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Ben,


  1. What version of the ArcGIS Viewer for Flex are you using?

  2. What is the locator url that you have configured and is it public? If it is not public can you attach a screenshot of the rest service page for the locator

  3. What is the version of ArcGIS Server you are using?

0 Kudos
BenAller
New Contributor III
Robert,

1. Using Flex v3.2
2. The geocode service url is not public but attached is a screen shot.  For what it's worth, it's a parcel locator that uses a relationship to our parcel address table.
3. Using Server 10.0

Thanks,
Ben
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Ben,


  1. When you click find address candidates at the bottom of the rest service page and type in a valid address can you screenshot the result page for me?

  2. Do you have anything in your LocateWidget.xml beside the <locator> tag? If so can you post your LocateWidget.xml?

0 Kudos
BenAller
New Contributor III
Here's the screenshot of the results page.  I did modify the LocateWidge.xml to appear more like a single line geocode service by setting the visibility of the zone field to false.   I also bumped down the minscore.  I did try commenting out the zone field line in the xml below and re-ran, but it didn't seem to change anything.

<?xml version="1.0" ?>
<configuration label="World Geocoding">
  <!--<locator>http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer</locator>-->
  <locator>http://dtarcgis10/arcgis/rest/services/Geocodeservices/Chesco_Address/GeocodeServer</locator>
  <minscore>66</minscore>
  <fields>
    <field name="Zone" alias="Muni Code" visible="false"/>
  </fields>
</configuration>
0 Kudos
AnthonyGiles
Frequent Contributor
Robert,

Sorry to jump in on this thread, but I would appreciate a little clarification on code syntax similar to what you have used in your example above:

locateResult.title = addrCandidate.address ? replaceMuniCodes(String(addrCandidate.address)) : widgetTitle;

I understand that the ? And : is shorthand for using an if else statement and locateResult.title will be set according to the statement being true or false, what I am unsure of is the addrCandidate.address as the condition, does this check if addrCandidate.address exists or if addrCandidate.address is empty.

Again sorry for hijacking the thread, i want to start writing neater code so a pointer would be appreciated

Regards

Anthony
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Anthony

   It is just checking if addrCandidate.address is null or not
0 Kudos
AnthonyGiles
Frequent Contributor
Thanks Robert
0 Kudos