smeijer / leaflet-geosearch

A geocoding/address-lookup library supporting various api providers.
https://smeijer.github.io/leaflet-geosearch/
MIT License
1.02k stars 271 forks source link

Cannot read property 'length' of undefined #257

Closed ipaidimarla closed 2 years ago

ipaidimarla commented 3 years ago

Hi, Whenever I type a letter in the input box, I am getting this error in my console. It is failing in autoSearch function. I am using OpenStreetMapProviders. And here is my code snippet

      const provider = new OpenStreetMapProvider({});
      const search = new GeoSearchControl({
        provider: provider,
        showMarker: true,
        autoClose: true,
        keepResult: true
      });
      map.addControl(search);

image

smeijer commented 3 years ago

What version of the lib do you use?

ipaidimarla commented 3 years ago

Hi, thanks for responding. I am using 3.0.5 and the context is a webcomponent

ipaidimarla commented 3 years ago

Hi, I am not able to figure out why I am getting this error, anyone has any idea?

yznts commented 3 years ago

@ipaidimarla Try to upgrade to the latest version (3.1.0 for now)

ipaidimarla commented 3 years ago

@yuriizinets, I tried that but it didn't help. I figured out that my parent container page is becoming the target of the search form input controller and this is causing the issue. Probably the issue is on my code and I am not sure how to avoid this.

smeijer commented 3 years ago

Are you able to share a small reproduction with codesandbox or codepen?

smeijer commented 2 years ago

Closing due to no response from OP.