summaryrefslogtreecommitdiff
path: root/snap.html
diff options
context:
space:
mode:
authorCode WvS <code-wvs@quantentunnel.de>2015-02-28 13:05:26 +0100
committerCode WvS <code-wvs@quantentunnel.de>2015-02-28 13:05:26 +0100
commit14369802342f49a440ce0700c4b86ef8682155ba (patch)
tree3a9ec11eb3da80f300da78f49ff6e103f3f1a9e8 /snap.html
parentb18e347b3716fd762ec5166c5f0df5d02aa5fed2 (diff)
downloadsnap-yow-14369802342f49a440ce0700c4b86ef8682155ba.tar.gz
snap-yow-14369802342f49a440ce0700c4b86ef8682155ba.zip
use a canvas as icon; do not rotate sprite twice
Diffstat (limited to 'snap.html')
-rwxr-xr-xsnap.html30
1 files changed, 19 insertions, 11 deletions
diff --git a/snap.html b/snap.html
index 3c4a9e4..04f44cd 100755
--- a/snap.html
+++ b/snap.html
@@ -27,22 +27,30 @@
<div id="map" style="position: absolute; width: 480px; height: 360px;" />
<!-- set initial size to 480x360 or the map will not load properly -->
<script type="text/javascript">
- L.SpriteMarker = L.Marker.extend({
+ L.SpriteIcon = L.Icon.extend({
options: {
- angle: 0
+ iconSize: [24, 24],
+ iconAnchor: [12, 12],
+ canvas: null,
+ className: 'leaflet-sprite-icon'
},
- _setPos: function (pos) {
- L.Marker.prototype._setPos.call(this, pos);
- this._icon.style[L.DomUtil.TRANSFORM] += ' rotate(' + this.options.angle + 'deg)';
- // TODO: set rotation center with transform-origin
+ createIcon: function () {
+ this.options.iconSize =
+ [this.options.canvas.width, this.options.canvas.height];
+ var copy = document.createElement('canvas');
+ copy.width = this.options.iconSize[0];
+ copy.height = this.options.iconSize[1];
+ var context = copy.getContext('2d');
+ context.drawImage(this.options.canvas, 0, 0);
+ this._setIconStyles(copy, 'icon');
+ return copy;
},
- setAngle: function (angle) {
- this.options.angle = angle;
- this.update();
+ createShadow: function (oldIcon) {
+ return null;
}
});
- L.spriteMarker = function(pos, options) {
- return new L.SpriteMarker(pos, options);
+ L.spriteIcon = function (options) {
+ return new L.SpriteIcon(options);
};
var world, map, layer, spriteGroup, defaultCostume;