cmv / cmv-app

CMV - The Configurable Map Viewer - A community supported open source mapping framework built with the Esri JavaScript API and the Dojo Toolkit
https://demo.cmv.io/
MIT License
325 stars 278 forks source link

how to change geocoding service from ESRI to mine? #629

Open JudyZhou opened 7 years ago

JudyZhou commented 7 years ago

I have my own geocoding service. how to change geocoder widget from ESRI's to mine? how to set a configuration? Thanks!

green3g commented 7 years ago

This should do it:

            geocoder: {
                include: true,
                type: 'domNode',
                path: 'esri/dijit/Search',
                srcNodeRef: 'searchDijit',
                options: {
                    map: true,
                    mapRightClickMenu: true,
                    enableInfoWindow: true
                    sources: [{
                       placeholder: 'Address, parcelid, place..',
                         locator: new Locator('arcgis/rest/services/internal/Sugg_Composite_Locator/GeocodeServer')
                     }]
                }
            },

You also need to include the locator object in your viewer's define block before it can be used.

define(['esri/tasks/locator'], function(Locator){

source: https://developers.arcgis.com/javascript/3/jssamples/search_customlocator.html

BTW @tmcgee docs need updating here for the search widget: http://docs.cmv.io/en/latest/widgets/Geocoder/

Maybe we should leave this open till the docs are fixed.

tmcgee commented 7 years ago

@roemhildtg I think the current documentation is accurate for the Esri Geocoder widget but perhaps it should be removed since that widget is no longer supported by Esri.

Your comment above is a good start at documentation for the newer Esri Search widget. (hint, hint. 😉)

green3g commented 7 years ago

I know, its like every day I catch stuff like this and figure, I should update the docs or something else, and at the end of the day, its like...where'd the day go?

JudyZhou commented 7 years ago

thanks both of you. @tmcgee @roemhildtg. I download Search widget from here. Can I use it to replace geocoder?

tmcgee commented 7 years ago

@JudyZhou You should not need to download anything. The example provided by @roemhildtg uses the Esri search widget which is part of recent versions of the Esri JavaScript API and so should work with your geocoder service.

JudyZhou commented 7 years ago

@tmcgee @roemhildtg I am working on ESRI Search widget. I got error at code locator: new Locator("http://cohgims.houstontx.gov/arcgis/rest/services/AddressLocators/Locator_composite/GeocodeServer"), error says: invalid URL. it is valid geocode service in public domain. if I use another geocode service locator: new Locator instead, got no error:("http://www.gims.houstontx.gov/ArcGIS/rest/services/Address_Locator_Zip_Street/GeocodeServer")

is restriction without www?

green3g commented 7 years ago

@JudyZhou I found your problem. The search widget uses the endpoint /suggest which isn't supported by your version of ArcGIS Server. (suggestions started at 10.3).

This issue is beyond my area of expertise, you may want to reach out to Esri for support on configuring the search widget with your version.

tmcgee commented 7 years ago

@roemhildtg Is the /suggest end point only for the type ahead functionality within the Esri search widget? My impression is the geocoding/search will still work. You just don't see the potential candidates as you type. I believe it also works at 10.3 when the suggestions are not explicitly enabled within the service.

I haven't spent a ton of time on this so may be off base. Is your experience with this different?

green3g commented 7 years ago

Yeah, that sounds correct. I also just looked at the api page and found the option enableSuggestions @JudyZhou maybe if you set this to false it will fix the error messages.