Skip to content

Commit f68f378

Browse files
committed
Initial commit
- Move layer from atogle/walkshed.js
0 parents  commit f68f378

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

VERSION

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2013, Aaron Ogle
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

src/Leaflet.ImageOverlay.Canvas.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*globals L */
2+
3+
/*
4+
* L.ImageOverlay is used to overlay images over the map (to specific geographical bounds).
5+
*/
6+
L.ImageOverlay.Canvas = L.ImageOverlay.extend({
7+
includes: L.Mixin.Events,
8+
9+
options: {
10+
opacity: 1
11+
},
12+
13+
initialize: function (bounds, options) { // (LatLngBounds, Object)
14+
this._bounds = L.latLngBounds(bounds);
15+
16+
L.Util.setOptions(this, options);
17+
},
18+
19+
_initImage: function () {
20+
var topLeft = this._map.latLngToLayerPoint(this._bounds.getNorthWest()),
21+
size = this._map.latLngToLayerPoint(this._bounds.getSouthEast())._subtract(topLeft);
22+
23+
this._image = this.canvas = L.DomUtil.create('canvas', 'leaflet-image-layer');
24+
this._image.width = size.x;
25+
this._image.height = size.y;
26+
27+
if (this._map.options.zoomAnimation && L.Browser.any3d) {
28+
L.DomUtil.addClass(this._image, 'leaflet-zoom-animated');
29+
} else {
30+
L.DomUtil.addClass(this._image, 'leaflet-zoom-hide');
31+
}
32+
33+
this._updateOpacity();
34+
35+
//TODO createImage util method to remove duplication
36+
L.Util.extend(this._image, {
37+
galleryimg: 'no',
38+
onselectstart: L.Util.falseFn,
39+
onmousemove: L.Util.falseFn,
40+
onload: L.Util.bind(this._onImageLoad, this)
41+
});
42+
},
43+
44+
_reset: function () {
45+
var image = this._image,
46+
topLeft = this._map.latLngToLayerPoint(this._bounds.getNorthWest()),
47+
size = this._map.latLngToLayerPoint(this._bounds.getSouthEast())._subtract(topLeft);
48+
49+
L.DomUtil.setPosition(image, topLeft);
50+
51+
image.style.width = size.x + 'px';
52+
image.style.height = size.y + 'px';
53+
},
54+
55+
_onImageLoad: function () {
56+
this.fire('load');
57+
}
58+
});
59+
60+
L.imageOverlay.canvas = function (bounds, options) {
61+
return new L.ImageOverlay.Canvas(bounds, options);
62+
};

0 commit comments

Comments
 (0)