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 convert undefined or null to object #251

Closed Kohlroulade closed 3 years ago

Kohlroulade commented 3 years ago

when I click on any of the results within my controls results, I get the mentioned error

This is my code:

async function initMap() {
      const map = L.map('map', {
        scrollWheelZoom: true
      });
      const provider = new GeoSearch.EsriProvider();
      // Query for the address
      const searchControl = new GeoSearch.GeoSearchControl({ provider: provider }).addTo(map);
}

I also tried the OSM-provider with the same result.

Here´s the stacktrace:

Uncaught (in promise) TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at NewClass.showResult (SearchControl.ts:412)
    at SearchControl.ts:404
showResult @ SearchControl.ts:412
(anonymous) @ SearchControl.ts:404
Promise.then (async)
onSubmit @ SearchControl.ts:401
handleClick @ SearchControl.ts:218
onClick @ resultList.ts:92

For some weird reason the statement this.markers._layers is undefined. I´m using the CDN from https://unpkg.com/leaflet-geosearch@3.0.0/dist/geosearch.umd.js

smeijer commented 3 years ago

Can you please try using the latest version? https://unpkg.com/leaflet-geosearch@3.1.0/dist/geosearch.umd.js

Kohlroulade commented 3 years ago

Yeap, that did it. Thank you

smeijer commented 3 years ago

Thanks for letting us know :+1:

jcrooke commented 2 years ago

Thanks, this worked for me. Might be a good idea to update https://smeijer.github.io/leaflet-geosearch/ docs