Closed ankit22687 closed 4 years ago
Only style of the code was changed. Indentation, etc. But no fix in sight
Go to line no. 645, 668 and 691. I wrap code with If conditions
I found. For which use-case do you introduce those modifications ? If you wrap those code lines into condition and icon object does not exist, bouncing doesn-t work at all, and this made the use of this pugin pointless
Unfortunately, the problem still exists. There ate no if statements in the master.
@tomek-servlets Can you please, present the minimal snippet that reproduce the bug. How do you create marker that has no icon ?
In my opinion before line 645 https://github.com/hosuaby/Leaflet.SmoothMarkerBouncing/blob/master/leaflet.smoothmarkerbouncing.js#L645 there should be if(icon) the same in the line 687
after adding of these statements there are no more errors in the console
@tomek-servlets is it bug or just console warning ?
If I remove the if before line 645 I get hundreds of errors:
leaflet.smoothmarkerbouncing.js:645 Uncaught TypeError: Cannot read property 'style' of undefined at makeMoveStep (leaflet.smoothmarkerbouncing.js:645)
@tomek-servlets Please, check this demo and tell me if you have error: http://hosuaby.github.io/Leaflet.SmoothMarkerBouncing/
On your page there I can see no errors.
I created a small page with errors. Click on the map and see the console: https://github.com/ironbone/leaflet-test
@ironbone Thanks for concrete example!
Your problem is easy to solve. You made a mistake by calling method bounce()
before add market to the map:
marker = L.marker(latlng, {icon: personIcon})
.bindPopup(popupText).bounce() // <- wrong place to call bounce
.setBouncingOptions({
bounceSpeed: bounceSpeed,
}).addTo(map);
To fix, just call bounce()
after addTo(map)
:
marker = L.marker(latlng, {icon: personIcon})
.bindPopup(popupText)
.setBouncingOptions({
bounceSpeed: bounceSpeed,
}).addTo(map).bounce(); // <- bounce called in the end
Thank you for your answer. This was not clear after reading the description of the plugin.
@ironbone I updated readme to outline importance to add market to map before call bounce()
method.
Found issue before set icon style, so I just wrap those with If condition and it is working fine now.