Leaflet Esri Geocoding search w/ GeoJSON layers

1891
1
Jump to solution
03-13-2017 11:44 AM
Labels (1)
BillChappell
Occasional Contributor II

I'm updating a leaflet app, it uses the L.esri.Geocoding.geosearch control, and beyond the geocoding it searches two featureServices. Now I have the requirement to search a geoJson layer. I've been unable to find a method to do this. The leaflet search works well for the GeoJson but not the featureLayers. Any ideas to avoid having two search controls on my map? 

0 Kudos
1 Solution

Accepted Solutions
JohnGravois
Frequent Contributor

the esri control is extensible so if you'd like to blend the functionality of both plugins one option would be to write a custom esri-leaflet-geocoder provider that makes AJAX requests for native GeoJSON features.

in the FeatureLayer provider below, the suggestions() and results() methods do the bulk of the work and both call query.run() to issue the actual web requests.  that's where you'd do your own thing.

esri-leaflet-geocoder/FeatureLayer.js at d990664e7e001bbd2676c958b3a276e696824f08 · Esri/esri-leafle... 

View solution in original post

0 Kudos
1 Reply
JohnGravois
Frequent Contributor

the esri control is extensible so if you'd like to blend the functionality of both plugins one option would be to write a custom esri-leaflet-geocoder provider that makes AJAX requests for native GeoJSON features.

in the FeatureLayer provider below, the suggestions() and results() methods do the bulk of the work and both call query.run() to issue the actual web requests.  that's where you'd do your own thing.

esri-leaflet-geocoder/FeatureLayer.js at d990664e7e001bbd2676c958b3a276e696824f08 · Esri/esri-leafle... 

0 Kudos