My Government Services - use internal geocoder

4517
7
Jump to solution
11-20-2015 02:40 PM
AllenScully
Occasional Contributor III

We have almost succeeded in re-wiring the My Government Services app for our own data.  Only remaining issue is changing the geocoder.

I've investiged this thread from 1.5 years ago:  Attempting to use custom locator with My Government Services

I'm still struggling to get ours working.  It is not a composite geocoder, so I have commented out the last 2 lines out.  This is what we have:

Locators: [{

            DisplayText: "Search Address", //Set placeholder text

            DefaultValue: "201 N STONE AV", // Set default address to search.

            LocatorParameters: ["SingleKey"], // Set Locator fields (fields to be used for searching).

            LocatorURL: "https://maps2.tucsonaz.gov/arcgis/rest/services/GISDATA_ADPARCEL_ADDRESS_MATCHER_WEB/GeocodeServer",

            CandidateFields: "Score, Match_addr, Ref_ID, Addr_type", //Set which fields are returned in results

            DisplayField: "${Match_addr}", //Set which field from results is displayed

            AddressMatchScore: 80 //Set minimum score to be considered a match

            //LocatorFieldName: 'Match_addr',//The returned field which specifies match type (specific locator within composite)

            //LocatorFieldValues: ["Address", "Addr", "Address_1", "Customer_Address"] //List of acceptable individual locators (within composite)

        }]

I've tried the Matchscore with and without a comma after it.

What we see in the map is simply 'No Results Found'  - no errors or anything, just not finding anything. 

The candidate fields are taken from the info on the rest services page for the geocoder service (it includes the shape field there for some reason, but did not include that in the candidate fields here).  My only theory is that there's a projection problem, since our geocoder is in our local state plane, but I'm assuming the map/app is Web Mercator?

Thanks

0 Kudos
1 Solution

Accepted Solutions
AdamDrackley
Occasional Contributor III

I think you still need to have those two values uncommented, Allen.  The Locator Field Name that gives the locator's type is called "Addr_type", whether or not the locator is participating in a Composite Locator.  Try the configuration below;

Locators: [{

            DisplayText: "Search Address", //Set placeholder text

            DefaultValue: "201 N STONE AV", // Set default address to search.

            LocatorParameters: ["SingleKey"], // Set Locator fields (fields to be used for searching).

            LocatorURL: "https://maps2.tucsonaz.gov/arcgis/rest/services/GISDATA_ADPARCEL_ADDRESS_MATCHER_WEB/GeocodeServer",

            CandidateFields: "Score, Match_addr, Ref_ID, Addr_type", //Set which fields are returned in results

            DisplayField: "${Match_addr}", //Set which field from results is displayed

            AddressMatchScore: 80, //Set minimum score to be considered a match

            LocatorFieldName: 'Addr_type',//The returned field which specifies match type (specific locator within composite)

            LocatorFieldValues: ["Address", "Addr", "Address_1", "Customer_Address"] //List of acceptable individual locators (within composite)

        }]

View solution in original post

0 Kudos
7 Replies
AdamDrackley
Occasional Contributor III

I think you still need to have those two values uncommented, Allen.  The Locator Field Name that gives the locator's type is called "Addr_type", whether or not the locator is participating in a Composite Locator.  Try the configuration below;

Locators: [{

            DisplayText: "Search Address", //Set placeholder text

            DefaultValue: "201 N STONE AV", // Set default address to search.

            LocatorParameters: ["SingleKey"], // Set Locator fields (fields to be used for searching).

            LocatorURL: "https://maps2.tucsonaz.gov/arcgis/rest/services/GISDATA_ADPARCEL_ADDRESS_MATCHER_WEB/GeocodeServer",

            CandidateFields: "Score, Match_addr, Ref_ID, Addr_type", //Set which fields are returned in results

            DisplayField: "${Match_addr}", //Set which field from results is displayed

            AddressMatchScore: 80, //Set minimum score to be considered a match

            LocatorFieldName: 'Addr_type',//The returned field which specifies match type (specific locator within composite)

            LocatorFieldValues: ["Address", "Addr", "Address_1", "Customer_Address"] //List of acceptable individual locators (within composite)

        }]

0 Kudos
AlisonGaiser1
Occasional Contributor

Thanks Adam.

0 Kudos
AllenScully
Occasional Contributor III

That worked perfectly - thanks Adam

0 Kudos
GabiVoicu
Occasional Contributor

I'm trying to do the same for the Election Polling Place sample and I can't figure out how to replace ESRI locator with our local in these settings

    LocatorSettings: {

        DefaultLocatorSymbol: "images/RedPushpin.png",

        SymbolSize: {

            width: 25,

            height: 25

        },

        DefaultValue: "2300 Bloomdale Rd., McKinney, TX 75071",

        LocatorParameters: ["SingleLine"],

        LocatorFields: ["Address", "City", "State", "Zip"],

        //LocatorURL: "http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer",

LocatorURL: "http://gis.co.collin.tx.us/arcgis/rest/services/geocoding/ROADS_DualRange/GeocodeServer",

        CandidateFields: "Loc_name, Score, Match_addr",

        FieldName: "${Match_addr}",

        LocatorFieldName: 'Loc_name',

        LocatorFieldValues: ["USA.StreetName", "USA.PointAddress", "USA.StreetAddress"],//notcomposite

        AddressMatchScore: 80,

        LocatorRippleSize: 40

    },

ClaireBrill
New Contributor III

I would also like to know how to replace the locator service settings to use geocoding service that I create with ArcGIS Server.  Is it possible to have two services, such that if the address doesn't match with the first (my point geocoder) it would be located by the second (Esri World geocoder)?

0 Kudos
AdamDrackley
Occasional Contributor III

Unfortunately, I don't think this kind of fallback approach would be possible without custom coding, Claire.

0 Kudos
AdamDrackley
Occasional Contributor III

Hey Gabi, hope things are well.  Would you be able to confirm if the link below is the version of the Election Polling Places app you're using?

Esri/election-polling-places: An applicatio... - GitHub

I've found that esri's boilerplate Locator code can be difficult at times to use with a custom address locator, so I'll point out a few things that are making it difficult for your GeocodeService to work smoothly with this template.

1) Line 37 of Esri's Locator code (/pollingPlaces/js/locator.js) is hardcoded to request a "Loc_name" field from your locator, which I believe only Composite Locators have.

     locator1.addressToLocations(address, ["Loc_name"], function (candidates) {...

You can replace that "Loc_name" with "*" to just return all fields in your locator.

2) The locator code will only list results that fall within the current extent of the map.  The returned coordinates that I get for looking up "2300 BLOOMDALE, MCKINNEY, TX, 75071 " in your locator look a bit wonky, and I was unable to get them to display even when I had the config file configured more or less correctly.

     X: -1.075748460615375E7

     Y: 3927251.2575993654

     Score: 89.04

     Address: 2300 BLOOMDALE, MCKINNEY, TX, 75071

3) With the coordinates and the hardcoding issues sorted out, you should be able to steer the locator from the config.js file.  There's likely better documentation out there on how to configure the config.js file for this particular app, but I configured youra similar to the following.  Note that "SingleLine" in the default data becomes "Single_Line_Input", because this is the actual name of the SingleLineAddressField returned by your service endpoint; http://gis.co.collin.tx.us/arcgis/rest/services/geocoding/ROADS_DualRange/GeocodeServer?f=pjson

    LocatorSettings: {

        DefaultLocatorSymbol: "images/RedPushpin.png",

        SymbolSize: {

            width: 25,

            height: 25

        },

        DefaultValue: "2300 Bloomdale Rd., McKinney, TX 75071",

        LocatorParameters: ["Single Line Input"],

        LocatorFields: ["Match_addr"],

        LocatorURL: "http://gis.co.collin.tx.us/arcgis/rest/services/geocoding/ROADS_DualRange/GeocodeServer/",

        CandidateFields: "Match_addr",

        FieldName: "${Match_addr}",

        LocatorFieldName: 'Match_addr',

        LocatorFieldValues: ["Match_addr"],

        AddressMatchScore: 80,

        LocatorRippleSize: 40

    },

The "Match_addr" field is just the full name of the returned address, as shown in a json request to your service http://gis.co.collin.tx.us/arcgis/rest/services/geocoding/ROADS_DualRange/GeocodeServer/findAddressC...

I hope this helps, or at least gets you started.