Custom Locator w/ Search Dijit

2796
5
Jump to solution
11-06-2015 06:28 AM
alexmoore
New Contributor II

Hello, I am having trouble implementing a custom locator task to be a source inside my existing Search dijit.

I've built a US Addresses Single House Address Locator from our customer data as I am unable to access ESRI's World Geocoding service from inside the company network.

The Address locator works in ArcGIS Desktop when I try it out, but I can't seem to get it to work in my JS app. Can't find any help on the JS API reference or forums elsewhere on how exactly to get this working. This seems like a straightforward problem but it evades me. Either says no results found or just keeps spinning like it's searching, depending how I tweak it. Any help is appreciated!

require([
    "esri/map",
    "esri/dijit/Search",
    "esri/tasks/locator"
], function (
        Map,
        Search,
        Locator
) {

var map = new Map("mapDiv", {
        basemap: "streets",
        center: [-84.6, 38.9],
        zoom: 11,
        infoWindow: popup,
        sliderStyle: "large"
    });
    map.on("load", mapReady);

var s = new Search({
        sources: [],
        enableButtonMode: false,
        enableLabel: false,
        enableInfoWindow: true,
        showInfoWindowOnSelect: true,
        zoomScale: 10000,
        map: map
    }, "search");
    s.startup();

var locator = new Locator("http://MYSERVER.MYCOMPANY.com/ArcGIS/rest/services/INFORMATICA_SHAPE_WM_2_AddrLoc/GeocodeServer");

var sources = s.get("sources")
    sources.push({
        locator: locator,
        name: "Address Search",
        singleLineFieldName: "Single Line Input",
        placeholder: "Find address or place",
        minCharacters: 8,
        outFields: ["*"]
    });
s.set("sources", sources);

0 Kudos
1 Solution

Accepted Solutions
SteveCole
Frequent Contributor

I'm assuming you saw this thread which addresses the same issue? Do you see any errors thrown in the console of the browser? Any network errors returned with the request?

Does the Geocoder work if you submit a request through the REST directory endpoint?

restEndpointQuery.jpg

View solution in original post

5 Replies
SteveCole
Frequent Contributor

I'm assuming you saw this thread which addresses the same issue? Do you see any errors thrown in the console of the browser? Any network errors returned with the request?

Does the Geocoder work if you submit a request through the REST directory endpoint?

restEndpointQuery.jpg

alexmoore
New Contributor II

After thinking about the issue I'm currently having, it might just be a boneheaded mistake by myself. I am trying to fix it real quick...will update when I know if it worked or not.

0 Kudos
alexmoore
New Contributor II

Well my quick fix did not work...not sure what I'm doing wrong here. I have point data with all the necessary fields in the correct spatial reference, I get no errors in creating the Locator. I use the locator in ArcGIS Desktop with no problems...it publishes to our ArcServer successfully...

I did try in the REST endpoint to Find Address Candidates and also the Reverse Geocode option and it never came back with results...I just get this...

And when I look in the console as I try to call the Locator, I get quite a few errors...ugh. Doesn't look good.

I didn't expect it to work when I called it in the app as I can't even get results in the endpoint, so hopefully when I get it to work in the services directory these errors will disappear. I hope.

0 Kudos
alexmoore
New Contributor II

I got frustrated and just decided to concatenate all my address data into one field and create a General Single Field address locator. Seems to have done the trick! I am able to get Address Candidates and Reverse geocode from the rest endpoint, and have successfully integrated it into my default Search dijit.

Thanks for the debugging help Steve.

SteveCole
Frequent Contributor

Cool. Glad you got it working!

0 Kudos