leaflet.bouncemarker

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

  • 所有者: maximeh/leaflet.bouncemarker
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

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.

主要指标

概览
名称与所有者maximeh/leaflet.bouncemarker
主编程语言JavaScript
编程语言JavaScript (语言数: 2)
平台
许可证MIT License
所有者活动
创建于2013-02-24 18:11:43
推送于2023-10-17 18:48:51
最后一次提交
发布数6
最新版本名称v1.2.3 (发布于 )
第一版名称v1.0 (发布于 2013-06-05 07:15:00)
用户参与
星数151
关注者数6
派生数52
提交数78
已启用问题?
问题数26
打开的问题数2
拉请求数11
打开的拉请求数0
关闭的拉请求数10
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?