perliedman / leaflet-control-geocoder

A simple geocoder form to locate places. Easily extended to multiple data providers.
http://www.liedman.net/leaflet-control-geocoder/
BSD 2-Clause "Simplified" License
560 stars 220 forks source link

Uncaught TypeError with release 2.0.0 in combination with MarkerCluster #312

Closed KristjanESPERANTO closed 3 years ago

KristjanESPERANTO commented 3 years ago

I get an Uncaught TypeError in the browser console when using the new version 2.0.0.

In Chrome the error message is:

Events.js:190 Uncaught TypeError: Cannot read property 'fn' of undefined
    at NewClass.fire (Events.js:190)
    at NewClass.removeLayer (Layer.js:200)
    at NewClass.eachLayer (LayerGroup.js:123)
    at NewClass.onRemove (LayerGroup.js:111)
    at NewClass.removeLayer (Layer.js:189)
    at NewClass.removeFrom (Layer.js:70)
    at NewClass.remove (Layer.js:59)
    at NewClass.onRemove (leaflet.markercluster-src.js:648)
    at NewClass.removeLayer (Layer.js:189)
    at v2.0.0.html:37

In Firefox the error message is:

Uncaught TypeError: l is undefined
    fire Events.js:190
    removeLayer Layer.js:200
    eachLayer LayerGroup.js:123
    onRemove LayerGroup.js:111
    removeLayer Layer.js:189
    removeFrom Layer.js:70
    remove Layer.js:59
    onRemove leaflet.markercluster-src.js:648
    removeLayer Layer.js:189
    <anonymous> v2.0.0.html:37

This looks like there is a problem in MarkerCluster, but when I use the old version of leaflet-control-geocoder this problem does not occur.

I've created a rudimentary example to comprehend the issue. The only difference is the version number of leaflet-control-geocoder. v1.13.0.html - old version without error v2.0.0.html - new version with error

gemmavnash commented 3 years ago

I've got the same error and I'm not using the marker clusterer, but I am using L.shapeMarker. So maybe it's paths or divIcons it has issues with? I'm using this library via unpkg across a lot of my portals, so really need this fixed asap. Please and thank you. Update; sorry, it's a similar error, not the same:

Events.js:190 Uncaught TypeError: Cannot read property 'fn' of undefined
    at i.fire (Events.js:190)
    at i.removeLayer (Layer.js:200)
    at i.closeTooltip (Tooltip.js:241)
    at i._close (Tooltip.js:118)
    at i.closeTooltip (Tooltip.js:349)
    at i.fire (Events.js:190)
    at i._fireDOMEvent (Map.js:1440)
    at i._handleDOMEvent (Map.js:1397)
    at HTMLDivElement.c (DomEvent.js:92)
mrAceT commented 3 years ago

Same here, I first thought the problem was with Markercluster or leaflet, but it starts when geocoder is initiated..

I made a test also: https://www.geoarchief.nl/test/GeoCoderBug.html

Thank you for mentioning the old version does not have the problem, will use that one for now..

mmcc5678 commented 3 years ago

Eugh, I just spent nearly 2 days trying to figure this. Such a N00b at JS but eventually...got here. Will make sure I version tie from here on in!

gemmavnash commented 3 years ago

I've just added the version to all my portals, and it's working again, so it's a lesson for me too. It didn't even cross my mind that a new version would be deployed at the same location.

simon04 commented 3 years ago

Sorry for breaking the event handling with the 2.0.0 release. Bringing together leaflet mixins and TypeScript wasn't easy and my approach for the 2.0.0 release turned out erroneous. A few minutes ago, I've released 2.0.1 which should address this issue.

KristjanESPERANTO commented 3 years ago

Thanks for the fast fix!

gemmavnash commented 3 years ago

thanks, that seems to have worked. 👍