Coder Social home page Coder Social logo

liuchuancong / leaflet.bouncemarker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from maximeh/leaflet.bouncemarker

0.0 1.0 0.0 40 KB

A plugin for Leaflet to have a bounce animation when adding a Marker to a map

License: MIT License

JavaScript 100.00%

leaflet.bouncemarker's Introduction

Bouncemarker plugin for Leaflet

This little plugin for Leaflet will make a Marker bounce when you add it on a map on whenever you want it to.

Watch the demo.

Version

Things may break in master, so please don't use this in production. There is tags which can be used in production.

Last stable: v1.2

Usage

Let's consider we have a Leaflet map:

var map = L.map('map');
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  attribution: 'Map data &copy; <a href="http://www.osm.org">OpenStreetMap</a>'
}).addTo(map);

onAdd

Make your marker bounce when you add them to a map.

L.marker([48.85, 2.35],
  {
    boolean bounceOnAdd,
    object bounceOnAddOptions,
    function bounceOnAddCallback
  }).addTo(map);

bounceOnAdd (boolean) (optional)

If true, your marker will bounce when added to the map. Default to false.

bounceOnAddOptions (object) (optional)

  • duration (integer) (Default: 1000)

    The duration of the animation in milliseconds.

  • height (integer) (Default: top_y)

    The height (in pixel) at which the marker is "dropped". The default is the top point on the y axis of the Marker.

  • loop (integer) (Default: 1)

    The number of times the animation should play. -1 is a special value for infinite loop.

bounceOnAddCallback (function) (optional)

If you specify the callback parameter, it will be called at the end of the animation.

Example:

L.marker([48.85, 2.35],
  {
    bounceOnAdd: true,
    bounceOnAddOptions: {duration: 500, height: 100, loop: 2},
    bounceOnAddCallback: function() {console.log("done");}
  }).addTo(map);

bounce

Make a marker bounce at anytime you wish.

bounce(object options, function callback);

Example:

marker = new L.Marker([48.85, 2.35], {bounceOnAdd: true}).addTo(map);
marker.on('click', function () {
    marker.bounce({duration: 500, height: 100});
});

options (object) (optional)

  • duration (integer) (Default: 1000)

    The duration of the animation in milliseconds.

  • height (integer) (Default: top_y)

    The height (in pixel) at which the marker is "dropped". The default is the top point on the y axis of the Marker.

  • loop (integer) (Default: 1)

    The number of times the animation should play. -1 is a special value for infinite loop.

callback (function) (optional)

If you specify the callback parameter, it will be called at the end of the animation.

Example:

marker.bounce({duration: 500, height: 100}, function(){console.log("done")});

stopBounce

Will stop the animation when called; the marker will be positionned at its destination.

leaflet.bouncemarker's People

Contributors

maximeh avatar leplatrem avatar beeglebug avatar danalloway avatar joaomsa avatar jfgodoy avatar petrabarus avatar gausie avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.