Esri / esri-leaflet-geocoder

helpers for using the ArcGIS World Geocoding Service in Leaflet
http://esri.github.io/esri-leaflet/examples/geocoding-control.html
Apache License 2.0
245 stars 101 forks source link

Custom Geocode Service with Suggestions Not Working (10.3.1) #182

Closed pmacMaps closed 7 years ago

pmacMaps commented 7 years ago

I decided to publish a geocoding service on our ArcGIS Server 10.3.1 with suggestions enabled. I'm testing it in a map where I'm using a feature layer provider and geocode service provider. The feature layer provider is working, but when I click on a geocode suggestion, nothing happens. This is a service using road centerlines.

I tested this service on WebAppBuilder developer edition 2.0, and in the launch/preview mode, the geocoding service works. I even tried having only the geocode service without the feature layer, and it still didn't work. We have other maps using our standard, non-suggestions geocode service (built pre-10.3.1), which does work.

jgravois commented 7 years ago

Non-working with suggestions: http://gis.ccpa.net/labs/leaflet-spa/medication-drop-boxes

when i slowly type "main st" into the search box in the top righthand corner of your app, results are returned from the suggest endpoint of your locator.

pmacMaps commented 7 years ago

Suggestions are returned, but when you select a suggestion nothing happens. But when you click on a suggestion from the feature layer, it zooms to the feature and opens a pop-up, which is the expected behavior.

Try "321 Gettysburg Pike" for a road, and "Carlisle" for the feature layer. If you type those into the map that is working with our other geocode service, you'll zoom to the result for both cases.

I'm using the same exact code for the results event:

/*** Address search results event ***/
addressSearchControl.on('results', function(data) {  
   // Remove previous result
   addressSearchResults.clearLayers();

   // make sure there is a result
   if (data.results.length > 0) {
      // set map view
      map.setView(data.results[0].latlng, 18);

      // open pop-up for location
      var popup = L.popup({closeOnClick: 
          true}).setLatLng(data.results[0].latlng).setContent(data.results[0].text).openOn(map);             
      }     
});
jgravois commented 7 years ago

thank you for clarifying.

the API should gather information internally and apply the parameter name your own custom geocoding service recognizes automatically. #183 ensures that that problem will be fixed in the future.

in the meantime, you can just hardcode it.

var ccpaProvider = L.esri.Geocoding.geocodeServiceProvider({
    url: 'https://gis.ccpa.net/arcgiswebadaptor/rest/services/Roads_Locator/GeocodeServer'
    // manually declare the parameter name for single line address search supported by your custom geocoding service
    customParam: 'Single Line Input'
});

that said, i noticed that the /suggest operation of your geocoding service is returning some suggestions that are not recognized by findAddressCandidates.

suggest?text=321 BRADI DR, CARLISLE

{
  "text": "321 BRADI DR, CARLISLE",
  "magicKey": "GST7YMc0AM9UOsKF",
  "isCollection": false
 }

findAddressCandidates ? 321 BRADI DR, CARLISLE

"candidates": []

there's nothing we can do about a problem like that from within esri leaflet.

jgravois commented 7 years ago

i've released v2.2.5 with the fix.

pmacMaps commented 7 years ago

that said, i noticed that the /suggest operation of your geocoding service is returning some suggestions that are not recognized by findAddressCandidates.

Is this likely an issue with how the address locator was built? Or something else? I don't want to tie up a non-Esri Leaflet Geocoder issue on this thread, but any direction in where to search to resolve this issue is appreciated.

And thanks for the new release.

jgravois commented 7 years ago

Is this likely an issue with how the address locator was built? Or something else?

tbh, i have no idea.

the doc here mentions the following caveat, "Only the locator styles provided by Esri can be used to build locators with suggestions enabled". Are you certain that the roads locator was created using an Esri style?

you also might want to check out this:

Enabling Suggestions on Custom Locators http://www.arcgis.com/home/item.html?id=d50dad552aca40c98a090e310ab8e038

if all else fails and you can't find anything relevant on geonet, i'd recommend logging a tech support call.