Esri / workflowmanager-viewer-js

Source code for ArcGIS Workflow Manager Classic JavaScript viewer - Manage your workflows on the web.
Apache License 2.0
26 stars 31 forks source link

More clear documentation on adding a custom location #10

Open nommuna2 opened 6 years ago

nommuna2 commented 6 years ago

There is a section in the AppConfig.js that lets you set your own Custom locator but there is no clear documentation on how to set the locatorSources array.

I thought all I would have to do is put in the URL to the locator as type string and it would set up the source for me but that does not seem to be the case. I would get errors saying that addressToLocations() is not a function.

So after doing a little bit of digging, looking at the JS API documentation, it seems that when creating a new source you need to give it an object and then specify the new locator as a new Locator type. In order to get this to work, I needed to add in the Locator class in the define method and then call it LocatorSources like so....

locatorSources: [{
                    locator: new Locator("https://sampleserver6.arcgisonline.com/arcgis/rest/services/Locators/SanDiego/GeocodeServer"),
                    singleLineFieldName: "SingleLine",
                    outFields: ["*"],
                    name: "i18n.widgets.Search.main.esriLocatorName",
                    placeholder: "i18n.widgets.Search.main.placeholder"

                }]

Only then did it work for me. I think it would be helpful if the documentation was updated to reflect this. Or if this is not supposed to work, then it may be a bug with using custom locators.

llam001 commented 6 years ago

Hello,

There is a link in the AppConfig.js configuration file about setting the locator sources: https://github.com/Esri/workflowmanager-viewer-js/blob/master/js/app/WorkflowManager/config/AppConfig.js#L168

This refers to the JavaScript API doc on setting sources: https://developers.arcgis.com/javascript/3/jsapi/search-amd.html#sources

Was there additional information that would have made it clearer?

Thanks for the feedback!

nommuna2 commented 6 years ago

Yes, I was following that documentation to set up the locator sources but I would get an error when I set up my locator like the example in my last comment above. The only way I got it to work is to include the Locator class in the AppConfig.jsfile. I needed to do this because I was defining a new Locator in the locatorSourcesarray, otherwise it would give me a Locator is not defined error.

I might be missing something but the documentation does not say anything about including additional classes to the AppConfig.js if you need to. I assumed that the other js files would have them included already but it does not seem to be the case.