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
244 stars 101 forks source link

Search control no longer can be added to map - bug #227

Closed kjrhody closed 5 years ago

kjrhody commented 5 years ago

The code update (2.3.0 on 10/10/19) appears to have broken the ability for our map to add the search control. We had it implemented as the following:

let searchControl = L.esri.Geocoding.geosearch().addTo(map);

It returned the following error:

Geosearch.js:230 Uncaught TypeError: Cannot read property 'length' of undefined
    at NewClass.onAdd (Geosearch.js:230)
    at NewClass.addTo (Control.js:70)
    at site.js:114  (this is where we are calling the searchControl line)

I then changed it to: let searchControl = L.esri.Geocoding.Geosearch().addTo(map); per the documentation here: https://esri.github.io/esri-leaflet/api-reference/controls/geosearch.html

And that returns the following error:

Class.js:26 Uncaught TypeError: this.callInitHooks is not a function
    at Object.NewClass [as Geosearch] (Class.js:26)
    at site.js:114

Last week we adjusted the bounds of our map, so I'm not sure if that could be the issue, but I don't think so? I tried this just in case, but it returns the same error as directly above.

let searchControl = L.esri.Geocoding.Geosearch({useMapBounds: true}).addTo(map);

Thanks for any help.

gavinr commented 5 years ago

This may be the same as #225

@kjrhody are you able to post the full code of your JS that causes this error? Then we can check to see if the fix for #225 will resolve your issue or if it's separate. Thanks!

kjrhody commented 5 years ago

I think you're right and it is the same issue - when I go to that line in the Geosearch.js it looks like the providers length is what is causing the problem:

    for (var i = 0; i < this.options.providers.length; i++) {
      this.options.providers[i]._contentsElement = DomUtil.create('div', null, this._suggestions);
    }

I can't post the whole thing unfortunately but I don't think we need to now!