-
-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e9cc8c
commit ba33829
Showing
3 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions
57
TeslaLogger/www/admin/static/leaflet/1.4.0/leaflet.rotatedMarker.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
(function() { | ||
// save these original methods before they are overwritten | ||
var proto_initIcon = L.Marker.prototype._initIcon; | ||
var proto_setPos = L.Marker.prototype._setPos; | ||
|
||
var oldIE = (L.DomUtil.TRANSFORM === 'msTransform'); | ||
|
||
L.Marker.addInitHook(function () { | ||
var iconOptions = this.options.icon && this.options.icon.options; | ||
var iconAnchor = iconOptions && this.options.icon.options.iconAnchor; | ||
if (iconAnchor) { | ||
iconAnchor = (iconAnchor[0] + 'px ' + iconAnchor[1] + 'px'); | ||
} | ||
this.options.rotationOrigin = this.options.rotationOrigin || iconAnchor || 'center bottom' ; | ||
this.options.rotationAngle = this.options.rotationAngle || 0; | ||
|
||
// Ensure marker keeps rotated during dragging | ||
this.on('drag', function(e) { e.target._applyRotation(); }); | ||
}); | ||
|
||
L.Marker.include({ | ||
_initIcon: function() { | ||
proto_initIcon.call(this); | ||
}, | ||
|
||
_setPos: function (pos) { | ||
proto_setPos.call(this, pos); | ||
this._applyRotation(); | ||
}, | ||
|
||
_applyRotation: function () { | ||
if(this.options.rotationAngle) { | ||
this._icon.style[L.DomUtil.TRANSFORM+'Origin'] = this.options.rotationOrigin; | ||
|
||
if(oldIE) { | ||
// for IE 9, use the 2D rotation | ||
this._icon.style[L.DomUtil.TRANSFORM] = 'rotate(' + this.options.rotationAngle + 'deg)'; | ||
} else { | ||
// for modern browsers, prefer the 3D accelerated version | ||
this._icon.style[L.DomUtil.TRANSFORM] += ' rotateZ(' + this.options.rotationAngle + 'deg)'; | ||
} | ||
} | ||
}, | ||
|
||
setRotationAngle: function(angle) { | ||
this.options.rotationAngle = angle; | ||
this.update(); | ||
return this; | ||
}, | ||
|
||
setRotationOrigin: function(origin) { | ||
this.options.rotationOrigin = origin; | ||
this.update(); | ||
return this; | ||
} | ||
}); | ||
})(); |