{"id":16401669,"url":"https://github.com/alejandrorm-dev/leaflet.markermotion","last_synced_at":"2025-07-16T18:33:41.032Z","repository":{"id":255442973,"uuid":"850895442","full_name":"AlejandroRM-DEV/Leaflet.MarkerMotion","owner":"AlejandroRM-DEV","description":"Leaflet.MarkerMotion is an open-source plugin for Leaflet that enables smooth marker animation along a predefined path. This plugin is perfect for visualizing routes, tracking objects in real-time, or creating engaging map-based animations.","archived":false,"fork":false,"pushed_at":"2024-09-24T04:31:24.000Z","size":366,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-31T21:34:40.712Z","etag":null,"topics":["leaflet","leaflet-plugin"],"latest_commit_sha":null,"homepage":"https://leaflet-marker-motion.vercel.app","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlejandroRM-DEV.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-02T03:20:54.000Z","updated_at":"2024-09-13T14:23:35.000Z","dependencies_parsed_at":"2024-09-14T03:13:34.203Z","dependency_job_id":null,"html_url":"https://github.com/AlejandroRM-DEV/Leaflet.MarkerMotion","commit_stats":null,"previous_names":["alejandrorm-dev/leaflet.markermotion"],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlejandroRM-DEV%2FLeaflet.MarkerMotion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlejandroRM-DEV%2FLeaflet.MarkerMotion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlejandroRM-DEV%2FLeaflet.MarkerMotion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlejandroRM-DEV%2FLeaflet.MarkerMotion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlejandroRM-DEV","download_url":"https://codeload.github.com/AlejandroRM-DEV/Leaflet.MarkerMotion/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238366827,"owners_count":19460193,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["leaflet","leaflet-plugin"],"created_at":"2024-10-11T05:43:51.716Z","updated_at":"2025-02-11T20:31:56.245Z","avatar_url":"https://github.com/AlejandroRM-DEV.png","language":"JavaScript","readme":"# Leaflet.MarkerMotion\n\nLeaflet.MarkerMotion is a powerful open-source plugin for Leaflet that enables smooth marker animation along predefined paths. Perfect for visualizing routes or creating engaging map-based animations.\n\n![Build Status](https://img.shields.io/github/actions/workflow/status/AlejandroRM-DEV/Leaflet.MarkerMotion/release.yml?branch=main)\n![npm version](https://img.shields.io/npm/v/leaflet.marker-motion)\n![npm](https://img.shields.io/npm/dt/leaflet.marker-motion)\n![License](https://img.shields.io/badge/license-MIT-blue)\n![GitHub issues](https://img.shields.io/github/issues/AlejandroRM-DEV/Leaflet.MarkerMotion)\n![GitHub forks](https://img.shields.io/github/forks/AlejandroRM-DEV/Leaflet.MarkerMotion)\n![GitHub stars](https://img.shields.io/github/stars/AlejandroRM-DEV/Leaflet.MarkerMotion)\n[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)\n\n## Features\n\n- Smooth marker animation along a predefined path\n- Configurable animation speed\n- Play, pause, and reset functionality\n- Marker rotation based on path direction\n- Autoplay and loop options\n- Easy integration with existing Leaflet projects\n\n## Demo\n\nCheck out our live demo: [https://leaflet-marker-motion.vercel.app](https://leaflet-marker-motion.vercel.app)\n\n## Installation\n\nInstall Leaflet.MarkerMotion via npm:\n\n```bash\nnpm install leaflet.marker-motion\n```\n\n## Usage\n\nHere's a basic example of how to use Leaflet.MarkerMotion:\n\n```javascript\n// Initialize the map\nconst map = L.map(\"map\").setView([22.634087, -102.983227], 14);\n\n// Add a tile layer\nL.tileLayer(\"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png\", {\n  maxZoom: 19,\n  attribution: '\u0026copy; \u003ca href=\"https://www.openstreetmap.org/copyright\"\u003eOpenStreetMap\u003c/a\u003e contributors',\n}).addTo(map);\n\n// Define the path\nconst points = [\n  [22.614407, -103.009848],\n  [22.622247, -103.006986],\n  // ... more points ...\n  [22.616452, -102.997295],\n];\n\n// Add the path as a polyline (optional)\nL.polyline(points).addTo(map);\n\n// Create a custom icon (optional)\nconst icon = L.icon({\n  iconUrl: \"./car.png\",\n  iconSize: [38, 38],\n  iconAnchor: [19, 19],\n});\n\n// Create and add the MarkerMotion\nconst speed = 40; // km/h\nconst markerMotion = L.markerMotion(points, speed, {\n  icon,\n  rotation: true,\n  autoplay: true,\n  loop: true\n}).addTo(map);\n\n// Listen for events (optional)\nmarkerMotion.on('motion.start', () =\u003e {\n  console.log('Motion started');\n});\n```\n\nFor more detailed example, check the `example` folder in the project repository.\n\n## API Reference\n\n### L.markerMotion(path, speedInKmH, options)\n\nCreates a new MarkerMotion instance.\n\n- `path`: Array of `L.LatLng` points defining the path.\n- `speedInKmH`: Speed of the marker in kilometers per hour.\n- `options`: Optional Leaflet marker options and MarkerMotion-specific options.\n\n#### MarkerMotion-specific options\n\n- `rotation` (boolean): Updates the rotation angle of the marker based on its current position and next point in the path.\n- `autoplay` (boolean): Starts animation automatically when added to the map.\n- `loop` (boolean): Restarts the animation from the beginning when it reaches the end of the path.\n\nAll standard Leaflet marker options are also supported.\n\n### Methods\n\n- `start()`: Starts or resumes the motion of the marker along the path.\n- `pause()`: Pauses the motion of the marker.\n- `reset()`: Stops the motion of the marker and resets it to the starting position.\n- `setSpeed(speedInKmH)`: Sets the speed of the marker in kilometers per hour.\n- `setProgress(index)`: Sets the progress of the marker to a specific segment of the path.\n- `isReady()`: Checks if the marker is in the READY state.\n- `isMoving()`: Checks if the marker is currently MOVING.\n- `isPaused()`: Checks if the marker motion is PAUSED.\n- `isEnded()`: Checks if the marker has ENDED its motion.\n\n### Events\n\n- `motion.start`: Fired when the motion starts or resumes.\n- `motion.pause`: Fired when the motion is paused.\n- `motion.reset`: Fired when the marker is reset to its starting position.\n- `motion.end`: Fired when the marker reaches the end of the path.\n- `motion.segment`: Fired when the marker enters a new segment of the path. Returns the current segment index.\n\n## Contributing\n\nContributions to Leaflet.MarkerMotion are welcome! Here's how you can contribute:\n\n1. Fork the repository\n2. Create a new branch (`git checkout -b feature/AmazingFeature`)\n3. Make your changes\n4. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n5. Push to the branch (`git push origin feature/AmazingFeature`)\n6. Open a Pull Request\n\nPlease make sure to update tests as appropriate and adhere to the existing coding style.\n\n## License\n\nDistributed under the MIT License. See `LICENSE` file for more information.\n\n## Acknowledgements\n\n- [Leaflet](https://leafletjs.com/) - The amazing library that makes this plugin possible\n- All contributors who help improve this project\n\n## Contact\n\nAlejandro Ramírez Muñoz - [GitHub](https://github.com/AlejandroRM-DEV)\n\nProject Link: [https://github.com/AlejandroRM-DEV/Leaflet.MarkerMotion](https://github.com/AlejandroRM-DEV/Leaflet.MarkerMotion)\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/AlejandroRM-DEV\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/8054357?v=4?s=100\" width=\"100px;\" alt=\"Alejandro Ramírez Muñoz\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAlejandro Ramírez Muñoz\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/AlejandroRM-DEV/Leaflet.MarkerMotion/commits?author=AlejandroRM-DEV\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falejandrorm-dev%2Fleaflet.markermotion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falejandrorm-dev%2Fleaflet.markermotion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falejandrorm-dev%2Fleaflet.markermotion/lists"}