Book Image

Leaflet.js Essentials

By : Paul Crickard III, Paul Crickard
Book Image

Leaflet.js Essentials

By: Paul Crickard III, Paul Crickard

Overview of this book

Table of Contents (13 chapters)
Leaflet.js Essentials
About the Author
About the Reviewers

Animating markers with plugins

In the next two sections, you will learn how to animate markers using the Leaflet.BounceMarker and Leaflet.AnimatedMarker plugins. Animation adds a wow factor to your map, but if overdone, it can make your map appear amateurish.

Bouncing your markers

The Leaflet.BounceMarker plugin does not have a large number of options to customize the markers or their behavior, but it provides a simple animation that is useful when you add markers to the map or on the hover event. You can download and learn more about the plugin at

The following steps will show you how to add a bounce marker to your map:

  1. Add a reference to the JavaScript file. There is no CSS file required for this plugin:

    <script src="bouncemarker.js"></script>	
  2. Creating a bounce marker is exactly the same as creating a standard Leaflet marker; the plugin adds an additional option to the L.Marker class. Because of this, the bounce marker has a bounceOnAdd...