question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property '_icon' of undefined

See original GitHub issue

I 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:closed
  • Created 8 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ghybscommented, Oct 20, 2015

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. The showMarker 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 from zoomend 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 are zoomToShowLayer and the spiderfication animations.

Hope this helps.

1reaction
ghostcommented, Oct 20, 2015

Thanks for your ideas.

For now I will check myself for __parent before calling a method zoomToShowLayer. 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found