locator - suggestionLocations - a working example?

1702
4
Jump to solution
03-16-2017 03:52 PM
Ravichandran_M_Kaushika
Occasional Contributor

dear Readers,

thanks a lot for taking the time to read my question:

https://developers.arcgis.com/javascript/3/jsapi/locator-amd.html#suggestlocations - has a simple example; I have made the changes as below:

 var params = {
                text: "addressInput",
                categoies: ["place", "address"],
                location: map.extent.getCenter().normalize(),
                distance: 1000
            };

            geocodeLocator.suggestLocations(params).then(function (suggestions) {
                console.log(suggestions);  // to start with.
            });

I have break points in this code (Chrome f12) and it is not hitting them. I am using esri/task/locator.

the address search is working fine - a single address search with NOresult storage on a database is working fine.  V r using the geocode engine belonging to ESRI.

the example url is not indicating it - do I need to capture dojo text entry into the addressInput text box - on. text change?

any information will be greatly appreciated.

regards

ravi.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Ravi,

   If you use the Search Dijit all of this is handled for you. But if you want to continue the route you are on, then yes you have to listen for the onChange event and fire the suggestLocations method. Also you  text: "addressInput", parameter is a fixed string. I don't think this is what you meant to do. If addressInput is the id of your text input then you need to get the value of that and set it to the text property of your options parameter.

View solution in original post

0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus

Ravi,

   If you use the Search Dijit all of this is handled for you. But if you want to continue the route you are on, then yes you have to listen for the onChange event and fire the suggestLocations method. Also you  text: "addressInput", parameter is a fixed string. I don't think this is what you meant to do. If addressInput is the id of your text input then you need to get the value of that and set it to the text property of your options parameter.

0 Kudos
Ravichandran_M_Kaushika
Occasional Contributor

Robert,

good afternoon.  thanks for your suggestions - i have made the function hunt for suggestion only if 3 characters are entered. I  was able to get to the server and obtained a bunch of suggestions - now I am trying to find a way to attach those 3 to 4 suggestions to the text box.

as always thanks to you for supporting the javascript community members.

have a good weekend.

regards

ravi.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Ravi,


   That is why I am asking why you are not using the Search dijit? The whole suggestions box and response to user clicks and everything is already coded and styled for you verses the route you are taking you will have to manually code this. You would have to build a div and place it under your text box and add click events to each list item you add as you loop through your suggestions and add each one to your div as a list item.

0 Kudos
Ravichandran_M_Kaushika
Occasional Contributor

Robert,

thanks - we started with the esri/dijit/geocode. but for some reason, the customers wanted to create an address locator that looked like the ArcObjects / arcmap interface.  there are a large number of users of this legacy product being brought to the web and they want to minimize training effort.

So all of us are going the extra miles for the javascript UI to behave or feel like arcmap client UI.

thanks for the div suggestion - I will work on that.

regards

ravi.

0 Kudos