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

Callback function ? #1

Open
nhinze opened this issue Nov 13, 2012 · 4 comments
Open

Callback function ? #1

nhinze opened this issue Nov 13, 2012 · 4 comments

Comments

@nhinze
Copy link
Contributor

nhinze commented Nov 13, 2012

Hi,

great little plugin. It would be nice to be able to define a callback function that would receive the current status of the animation (current distance travelled, lat/long, time?) so that events can be triggered along the path when the marker reaches a certain spot. I'm hacking it it right now, but it would be a nice feature.

Thanks,

Nick,

@atogle
Copy link
Member

atogle commented Nov 13, 2012

Thanks @nhinze. That's a really interesting idea. I'll try to carve out some time for it. I'm happy to help out with questions if you want to take a stab at it.

@nhinze
Copy link
Contributor Author

nhinze commented Nov 13, 2012

I added a little pull request that shows how I edited your code to send the distance travelled to a custom function at each interval. However, something cleaner would be nice. I'm not very familiar with leaflet yet.

@atogle
Copy link
Member

atogle commented Nov 14, 2012

Thank @nhinze. I glanced at it and I think there's probably a better way to tackle it. Your solution calls the callback at each vertex which could end up being less an ideal if you have a line that's 100 miles long but only a start and end point, for example. You'd only get callbacks on start and finish.

@mourner recommended that I check out the new DomPosition util to implement the animation. There might be something in there to help.

Again, thanks for the idea and the code ideas. Much appreciated!

@nhinze
Copy link
Contributor Author

nhinze commented Nov 14, 2012

Actually, the hack I did calls the function at minimum at each "interval". I have it set at 1000 ms, so I get a position/distance update at least every 1s. However, I do agree that my hack is a dirty solution and there is probably a better way.

atogle pushed a commit that referenced this issue Jan 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants