Cannot read property '_icon' of undefined
See original GitHub issueI can’t reproduce this bug, but I get notifications from time to time on Opbeat, when ‘animationend’ is fired in L.MarkerClusterGroup.include.L.DomUtil.TRANSITION._animationEnd, and showMarker
method tries to check if ((layer._icon || layer.__parent._icon) && !this._inZoomAnimation)
, and apparently __parent does not exist (see StackTrace at the bottom).
I’m not very familiar with Leaflet’s code, but if the __parent is not always available, would it be worth checking if ((layer._icon || (layer.__parent && layer.__parent._icon)) && !this._inZoomAnimation)
?
StackTrace: L.MarkerClusterGroup.include.L.DomUtil.TRANSITION._animationEnd L.Mixin.Events.fireEvent showMarker ?
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Uncaught TypeError: Cannot read property 'icon' of undefined ...
This seems to be causing the error (inside the js bundle):. function define(prefix, icons) { var normalized = Object.keys(icons).reduce(function ...
Read more >TypeError: Cannot read properties of undefined (reading 'Icon ...
Here the error is coming from line 2: value: {Icon, name, level} . The value coming via props seems to be undefined.
Read more >cannot read properties of undefined (reading 'icon') - You.com
Here the error is coming from line 2: value: {Icon, name, level} . The value coming via props seems to be undefined. Check...
Read more >Inertia Vue3 and FontAwesome 6 - Laracasts
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'icon'). I thought I was getting used to Vue3, it's my first time...
Read more >How to Prevent the TypeError: Cannot Read Property Map of ...
As a result, the TypeError Cannot read property 'map' of undefined is very common and one of the first errors that developers will...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi,
Well you are probably on it with Leaflet.Deflate.
If you actually remove your marker from MCG (besides from the map or not), then the marker loses its
__parent
property, and it will not get a new one because it is replaced by another object. TheshowMarker
callback does not know it should now refer to that other object. Furthermore, even if that object is added to MCG, since it is a non-point feature, MCG will not be able to use (cluster) it and it will not assign a__parent
property to it.Why not using the callback of
zoomToShowLayer
to implement your conversion when triggering that method? That way you would ensure the marker is untouched until MCG no longer needs it. You would need to temporarily remove your listener fromzoomend
however.We could still add a check on the existence of the
__parent
property, though. Better (but more complicated), we might need to assume that markers can be removed in the middle of an animation (as seems to be your case). I think the places that would be affected arezoomToShowLayer
and the spiderfication animations.Hope this helps.
Thanks for your ideas.
For now I will check myself for
__parent
before calling a methodzoomToShowLayer
. This should be the same as checking it inside the method, right? I will let you know if I’m still getting notifications after the change.