2 * L.Handler.MarkerDrag is used internally by L.Marker to make the markers draggable.
5 L
.Handler
.MarkerDrag
= L
.Handler
.extend({
6 initialize: function(marker
) {
11 if (this._enabled
) { return; }
12 if (!this._draggable
) {
13 this._draggable
= new L
.Draggable(this._marker
._icon
, this._marker
._icon
);
14 this._draggable
.on('dragstart', this._onDragStart
, this);
15 this._draggable
.on('drag', this._onDrag
, this);
16 this._draggable
.on('dragend', this._onDragEnd
, this);
18 this._draggable
.enable();
23 if (!this._enabled
) { return; }
24 this._draggable
.disable();
25 this._enabled
= false;
29 return this._draggable
&& this._draggable
._moved
;
32 _onDragStart: function(e
) {
33 this._marker
.closePopup();
35 this._marker
.fire('movestart');
36 this._marker
.fire('dragstart');
39 _onDrag: function(e
) {
40 // update shadow position
41 var iconPos
= L
.DomUtil
.getPosition(this._marker
._icon
);
42 L
.DomUtil
.setPosition(this._marker
._shadow
, iconPos
);
44 this._marker
._latlng
= this._marker
._map
.layerPointToLatLng(iconPos
);
46 this._marker
.fire('move');
47 this._marker
.fire('drag');
50 _onDragEnd: function() {
51 this._marker
.fire('moveend');
52 this._marker
.fire('dragend');