hosuaby / Leaflet.SmoothMarkerBouncing

Smooth animation of marker bouncing for Leaflet.
BSD 2-Clause "Simplified" License
146 stars 28 forks source link

Exception after reloading Leaflet Map with bouncing marker #30

Closed tuzzo77 closed 2 years ago

tuzzo77 commented 3 years ago

Hi, thanks for your implementation of marker.

I've an excpetion refreshing map markers with bouncing effect. Can you help me please?

Thanks

Uncaught TypeError: Cannot read property 'recalculateMotion' of undefined at i.setPos (bundle.js?=1611847560584:1300) at i._animateZoom (Marker.js:313) at i.fire (Events.js:190) at i._animateZoom (Map.js:1689) at i. (Map.js:1667)

hosuaby commented 3 years ago

Hello, @tuzzo77

Can you give a snippet with code that create this problem ?

FelipeACP commented 2 years ago

I guess https://github.com/hosuaby/Leaflet.SmoothMarkerBouncing/commit/193d2982f1d1bfa789b7b0914512ced48be2b5c3 should have fixed it, but I'm not sure if it was published.

hosuaby commented 2 years ago

@FelipeACP Non, this commit was not published. It makes part of the next major release, fully based on CSS3 animations. Current version 2.0.1 works well with clusters. If this is not a case, I invite you to share the code snippet that cause a problem.

FelipeACP commented 2 years ago

This error happens occasionally: https://i.imgur.com/EteHTqS.png

This is how I've been using: https://gist.github.com/FelipeACP/a1cf58ebb2a6f2b72db6851c94d05daf

If it doesn't help, I'll try and create a minimal reproducible example

EDIT:

After spending quite a while debugging this issue, I found that this may be caused by some race condition where this library was called after the leaflet object context had been set. As a result, this._bouncingMotion was undefined on the first render. After I had this lib imported into the project root, the error message seems to have stopped.

hosuaby commented 2 years ago

@FelipeACP I noticed that your code changes icon and z-index. It's not a good thing to do while using this plugin. If you need to change icon of the marker, I advise you to remove the marker first and create a new one with new icon; https://github.com/hosuaby/Leaflet.SmoothMarkerBouncing/issues/26

hosuaby commented 2 years ago

It is possible to change icon of bouncing marker starting from version 3.0.1.