hosuaby / Leaflet.SmoothMarkerBouncing

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

Uncaught TypeError: _this$marker$getIcon$.iconSize is undefined #33

Closed awerner25 closed 2 years ago

awerner25 commented 3 years ago

Hello,

I just add your library and I have an error.

<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
crossorigin=""></script>
<script type="text/javascript"
        src="https://cdn.jsdelivr.net/gh/hosuaby/Leaflet.SmoothMarkerBouncing@v2.0.0/dist/bundle.js"
        crossorigin="anonymous"></script>
<script>
[...]
var marker = L.marker([location.latitude, location.longitude], {icon: icons[location.category.pk]}).addTo(mymap);
</script>

Error:

Uncaught TypeError: _this$marker$getIcon$.iconSize is undefined
    recalculateMotion bundle.js:822
    updateBouncingOptions bundle.js:470
    BouncingMotion bundle.js:440
    _createSuperInternal bundle.js:115
    BouncingMotion3D bundle.js:800
    createBouncingMotion bundle.js:1322
    <anonymous> bundle.js:1355
    callInitHooks Class.js:78
    i Class.js:26
    marker Marker.js:385
    <anonymous> (index):901
    <anonymous> (index):900
    jQuery 13
bundle.js:822:231

If I remove {icon: icons[location.category.pk]}, it's works

awerner25 commented 3 years ago

I found the solution, I have to specify the size of the icons (which is not mandatory for the leaflet library)

hosuaby commented 3 years ago

Hello @darkvodka Great that you found solution so fast. Yes, in order to calculate frames of animations, this plugin need to know the size of icon. If you use default Leaflet icons, its size is defined already. In case someon else will have this trouble, I leave here an example with default and customs icons: https://github.com/hosuaby/Leaflet.SmoothMarkerBouncing/blob/gh-pages/resources/scripts/app.js