Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed "Property style on undefined" #23

Closed
wants to merge 1 commit into from

Conversation

ankit22687
Copy link

Found issue before set icon style, so I just wrap those with If condition and it is working fine now.

@hosuaby
Copy link
Owner

hosuaby commented Aug 25, 2019

Only style of the code was changed. Indentation, etc. But no fix in sight

@ankit22687
Copy link
Author

Go to line no. 645, 668 and 691. I wrap code with If conditions

@hosuaby
Copy link
Owner

hosuaby commented Aug 27, 2019

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

@ankit22687 ankit22687 closed this Aug 28, 2019
@ankit22687 ankit22687 deleted the fix_issue_no_21 branch August 28, 2019 02:45
@tomek-servlets
Copy link

Unfortunately, the problem still exists. There ate no if statements in the master.

@hosuaby
Copy link
Owner

hosuaby commented Jul 4, 2020

@tomek-servlets
Can you please, present the minimal snippet that reproduce the bug. How do you create marker that has no icon ?

@tomek-servlets
Copy link

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

@hosuaby
Copy link
Owner

hosuaby commented Jul 4, 2020

@tomek-servlets is it bug or just console warning ?

@tomek-servlets
Copy link

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)

@hosuaby
Copy link
Owner

hosuaby commented Jul 6, 2020

@tomek-servlets
Please, check this demo and tell me if you have error:
http://hosuaby.github.io/Leaflet.SmoothMarkerBouncing/

@ironbone
Copy link

ironbone commented Jul 6, 2020

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

@hosuaby
Copy link
Owner

hosuaby commented Jul 13, 2020

@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

@ironbone
Copy link

Thank you for your answer.
This was not clear after reading the description of the plugin.

@hosuaby
Copy link
Owner

hosuaby commented Jul 14, 2020

@ironbone I updated readme to outline importance to add market to map before call bounce() method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants