hosuaby / Leaflet.SmoothMarkerBouncing

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

icon is undefined error at bouncing. #13

Closed andesim closed 6 years ago

andesim commented 6 years ago

Although apparently everything seems to work, I receive this error at every marker bounce:

TypeError: icon is undefined[Ulteriori informazioni] leaflet.smoothmarkerbouncing.js:631:17 makeMoveStep http://10.250.0.69:9967/leaflet.smoothmarkerbouncing.js:631:17

the code is this: function creaIncidente(e) { var incIcon = new L.ExtraMarkers.icon({ iconUrl: '/images/icons/incident.png', iconColor : 'white', markerColor : 'orange-dark', shape : 'penta', pulsing : "myglow" }); var lat = e.latlng.lat; var lng = e.latlng.lng; var marker = new L.marker([lat,lng], { icon: incIcon, zIndexOffset: 1000 }).bounce(); LAYERS[9999].layer = marker; LAYERS[9999].layer.addTo(map); ..........

i've just tried to to replace L.ExtraMarker.icon with this standard: var incIcon = new L.icon({ iconUrl: '/images/unique.png', shadowUrl: 'images/unique-shadow.png', iconSize: [33, 44], // size of the icon shadowSize: [38, 25], // size of the shadow iconAnchor: [17, 44], // point of the icon which will correspond to marker's location shadowAnchor: [6, 25], // the same for the shadow popupAnchor: [0, -46], // point from which the popup should open relative to the iconAnchor }); but I receive the same error on the web browser console.

hosuaby commented 6 years ago

@andesim Please, check first examples from folder debug. It shows use-cases with all kind of icons.

andesim commented 6 years ago

@hosuaby i have tried to apply some settings from debug folder but the error "TypeError: icon is undefined" is still present on makeResizeStep and makeMoveStep. But anyway the "incIcon" marker is bouncing.

hosuaby commented 6 years ago

The problem here is that you call .bounce() on marker before add it to the map. You must first make marker.addTo(map) et just after marker.bounce()

ZhukDmitry commented 5 years ago

Hi. When I use clusterer https://leaflet.github.io/Leaflet.markercluster/

I've got bouncing marker, but in console there are a lot of errors TypeError: icon is null[Подробнее] leaflet.smoothmarkerbouncing.js:645:17 TypeError: icon is null[Подробнее] leaflet.smoothmarkerbouncing.js:687:17

It is not depend on clustered placemark or visible.

hosuaby commented 5 years ago

@ZhukDmitry exemple https://github.com/hosuaby/Leaflet.SmoothMarkerBouncing/blob/master/debug/cluster.html shows how plugin works with cluster. Please, check it.

ZhukDmitry commented 5 years ago

Hi. Thanks for reply. I prepared page with explaination and examples. It is simple map with 2 placemarks. I think you will understand me. Check here https://zhuk.cc/tmp/SmoothMarkerBouncing/test.htm