leaflet-ruby 0.3.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +5 -0
- data/LICENSE +21 -0
- data/README.rdoc +55 -0
- data/Rakefile +15 -0
- data/leaflet-ruby.gemspec +24 -0
- data/lib/leaflet-ruby.rb +18 -0
- data/lib/leaflet/CHANGELOG.md +181 -0
- data/lib/leaflet/Jakefile.js +65 -0
- data/lib/leaflet/LICENSE +22 -0
- data/lib/leaflet/README.md +32 -0
- data/lib/leaflet/build/build.html +243 -0
- data/lib/leaflet/build/build.js +79 -0
- data/lib/leaflet/build/deps.js +231 -0
- data/lib/leaflet/build/hint.js +30 -0
- data/lib/leaflet/build/hintrc.js +44 -0
- data/lib/leaflet/debug/control/control-layers.html +47 -0
- data/lib/leaflet/debug/control/map-control.html +29 -0
- data/lib/leaflet/debug/css/mobile.css +6 -0
- data/lib/leaflet/debug/css/screen.css +5 -0
- data/lib/leaflet/debug/geojson/geojson-sample.js +53 -0
- data/lib/leaflet/debug/geojson/geojson.html +56 -0
- data/lib/leaflet/debug/leaflet-include.js +120 -0
- data/lib/leaflet/debug/map/canvas.html +46 -0
- data/lib/leaflet/debug/map/map-mobile.html +42 -0
- data/lib/leaflet/debug/map/map.html +54 -0
- data/lib/leaflet/debug/map/max-bounds.html +36 -0
- data/lib/leaflet/debug/map/scroll.html +35 -0
- data/lib/leaflet/debug/map/wms-marble.html +30 -0
- data/lib/leaflet/debug/map/wms.html +37 -0
- data/lib/leaflet/debug/vector/editable.html +43 -0
- data/lib/leaflet/debug/vector/route.js +1 -0
- data/lib/leaflet/debug/vector/vector-bounds.html +69 -0
- data/lib/leaflet/debug/vector/vector-canvas.html +92 -0
- data/lib/leaflet/debug/vector/vector-mobile.html +38 -0
- data/lib/leaflet/debug/vector/vector-simple.html +63 -0
- data/lib/leaflet/debug/vector/vector.html +38 -0
- data/lib/leaflet/dist/images/layers.png +0 -0
- data/lib/leaflet/dist/images/marker-shadow.png +0 -0
- data/lib/leaflet/dist/images/marker.png +0 -0
- data/lib/leaflet/dist/images/popup-close.png +0 -0
- data/lib/leaflet/dist/images/zoom-in.png +0 -0
- data/lib/leaflet/dist/images/zoom-out.png +0 -0
- data/lib/leaflet/dist/leaflet-src.js +5537 -0
- data/lib/leaflet/dist/leaflet.css +323 -0
- data/lib/leaflet/dist/leaflet.ie.css +48 -0
- data/lib/leaflet/dist/leaflet.js +6 -0
- data/lib/leaflet/lib/jasmine/jasmine-html.js +182 -0
- data/lib/leaflet/lib/jasmine/jasmine.css +166 -0
- data/lib/leaflet/lib/jasmine/jasmine.js +2421 -0
- data/lib/leaflet/spec/runner.html +57 -0
- data/lib/leaflet/spec/suites/LeafletSpec.js +15 -0
- data/lib/leaflet/spec/suites/SpecHelper.js +28 -0
- data/lib/leaflet/spec/suites/core/ClassSpec.js +153 -0
- data/lib/leaflet/spec/suites/core/EventsSpec.js +110 -0
- data/lib/leaflet/spec/suites/core/UtilSpec.js +63 -0
- data/lib/leaflet/spec/suites/dom/DomEventSpec.js +102 -0
- data/lib/leaflet/spec/suites/dom/DomUtilSpec.js +59 -0
- data/lib/leaflet/spec/suites/geo/LatLngBoundsSpec.js +1 -0
- data/lib/leaflet/spec/suites/geo/LatLngSpec.js +76 -0
- data/lib/leaflet/spec/suites/geo/ProjectionSpec.js +42 -0
- data/lib/leaflet/spec/suites/geometry/BoundsSpec.js +53 -0
- data/lib/leaflet/spec/suites/geometry/PointSpec.js +45 -0
- data/lib/leaflet/spec/suites/geometry/TransformationSpec.js +19 -0
- data/lib/leaflet/spec/suites/layer/TileLayerSpec.js +1 -0
- data/lib/leaflet/spec/suites/layer/vector/PolylineGeometrySpec.js +35 -0
- data/lib/leaflet/spec/suites/map/MapSpec.js +1 -0
- data/lib/leaflet/src/Leaflet.js +33 -0
- data/lib/leaflet/src/control/Control.Attribution.js +66 -0
- data/lib/leaflet/src/control/Control.Layers.js +167 -0
- data/lib/leaflet/src/control/Control.Zoom.js +36 -0
- data/lib/leaflet/src/control/Control.js +9 -0
- data/lib/leaflet/src/core/Browser.js +53 -0
- data/lib/leaflet/src/core/Class.js +66 -0
- data/lib/leaflet/src/core/Events.js +62 -0
- data/lib/leaflet/src/core/Handler.js +29 -0
- data/lib/leaflet/src/core/Util.js +108 -0
- data/lib/leaflet/src/dom/DomEvent.DoubleTap.js +43 -0
- data/lib/leaflet/src/dom/DomEvent.js +154 -0
- data/lib/leaflet/src/dom/DomUtil.js +155 -0
- data/lib/leaflet/src/dom/Draggable.js +147 -0
- data/lib/leaflet/src/dom/transition/Transition.Native.js +102 -0
- data/lib/leaflet/src/dom/transition/Transition.Timer.js +126 -0
- data/lib/leaflet/src/dom/transition/Transition.js +28 -0
- data/lib/leaflet/src/geo/LatLng.js +44 -0
- data/lib/leaflet/src/geo/LatLngBounds.js +86 -0
- data/lib/leaflet/src/geo/crs/CRS.EPSG3395.js +13 -0
- data/lib/leaflet/src/geo/crs/CRS.EPSG3857.js +17 -0
- data/lib/leaflet/src/geo/crs/CRS.EPSG4326.js +7 -0
- data/lib/leaflet/src/geo/crs/CRS.js +17 -0
- data/lib/leaflet/src/geo/projection/Projection.LonLat.js +10 -0
- data/lib/leaflet/src/geo/projection/Projection.Mercator.js +51 -0
- data/lib/leaflet/src/geo/projection/Projection.SphericalMercator.js +23 -0
- data/lib/leaflet/src/geo/projection/Projection.js +5 -0
- data/lib/leaflet/src/geometry/Bounds.js +50 -0
- data/lib/leaflet/src/geometry/LineUtil.js +194 -0
- data/lib/leaflet/src/geometry/Point.js +66 -0
- data/lib/leaflet/src/geometry/PolyUtil.js +59 -0
- data/lib/leaflet/src/geometry/Transformation.js +31 -0
- data/lib/leaflet/src/layer/FeatureGroup.js +40 -0
- data/lib/leaflet/src/layer/GeoJSON.js +104 -0
- data/lib/leaflet/src/layer/ImageOverlay.js +58 -0
- data/lib/leaflet/src/layer/LayerGroup.js +74 -0
- data/lib/leaflet/src/layer/Popup.js +179 -0
- data/lib/leaflet/src/layer/marker/Icon.js +58 -0
- data/lib/leaflet/src/layer/marker/Marker.Drag.js +57 -0
- data/lib/leaflet/src/layer/marker/Marker.Popup.js +42 -0
- data/lib/leaflet/src/layer/marker/Marker.js +142 -0
- data/lib/leaflet/src/layer/tile/TileLayer.Canvas.js +41 -0
- data/lib/leaflet/src/layer/tile/TileLayer.WMS.js +47 -0
- data/lib/leaflet/src/layer/tile/TileLayer.js +310 -0
- data/lib/leaflet/src/layer/vector/Circle.js +68 -0
- data/lib/leaflet/src/layer/vector/CircleMarker.js +25 -0
- data/lib/leaflet/src/layer/vector/MultiPoly.js +34 -0
- data/lib/leaflet/src/layer/vector/Path.Popup.js +24 -0
- data/lib/leaflet/src/layer/vector/Path.SVG.js +138 -0
- data/lib/leaflet/src/layer/vector/Path.VML.js +93 -0
- data/lib/leaflet/src/layer/vector/Path.js +88 -0
- data/lib/leaflet/src/layer/vector/Polygon.js +64 -0
- data/lib/leaflet/src/layer/vector/Polyline.js +146 -0
- data/lib/leaflet/src/layer/vector/canvas/Circle.Canvas.js +18 -0
- data/lib/leaflet/src/layer/vector/canvas/Path.Canvas.js +146 -0
- data/lib/leaflet/src/layer/vector/canvas/Polygon.Canvas.js +34 -0
- data/lib/leaflet/src/layer/vector/canvas/Polyline.Canvas.js +27 -0
- data/lib/leaflet/src/map/Map.js +613 -0
- data/lib/leaflet/src/map/anim/Map.PanAnimation.js +70 -0
- data/lib/leaflet/src/map/anim/Map.ZoomAnimation.js +133 -0
- data/lib/leaflet/src/map/ext/Map.Control.js +50 -0
- data/lib/leaflet/src/map/ext/Map.Geolocation.js +86 -0
- data/lib/leaflet/src/map/ext/Map.Popup.js +20 -0
- data/lib/leaflet/src/map/handler/Map.BoxZoom.js +73 -0
- data/lib/leaflet/src/map/handler/Map.DoubleClickZoom.js +18 -0
- data/lib/leaflet/src/map/handler/Map.Drag.js +81 -0
- data/lib/leaflet/src/map/handler/Map.ScrollWheelZoom.js +55 -0
- data/lib/leaflet/src/map/handler/Map.TouchZoom.js +93 -0
- data/lib/zerista/CRS.Cartesian.js +20 -0
- data/lib/zerista/Projection.Identity.js +11 -0
- data/lib/zerista/zerista_layer.js +97 -0
- data/vendor/assets/javascripts/leaflet.js +139 -0
- data/vendor/assets/stylesheets/leaflet.css +1 -0
- data/vendor/assets/stylesheets/leaflet.ie.css +1 -0
- metadata +185 -0
@@ -0,0 +1,102 @@
|
|
1
|
+
/*
|
2
|
+
* L.Transition native implementation that powers Leaflet animation
|
3
|
+
* in browsers that support CSS3 Transitions
|
4
|
+
*/
|
5
|
+
|
6
|
+
L.Transition = L.Transition.extend({
|
7
|
+
statics: (function () {
|
8
|
+
var transition = L.DomUtil.TRANSITION,
|
9
|
+
transitionEnd = (transition === 'webkitTransition' || transition === 'OTransition' ?
|
10
|
+
transition + 'End' : 'transitionend');
|
11
|
+
|
12
|
+
return {
|
13
|
+
NATIVE: !!transition,
|
14
|
+
|
15
|
+
TRANSITION: transition,
|
16
|
+
PROPERTY: transition + 'Property',
|
17
|
+
DURATION: transition + 'Duration',
|
18
|
+
EASING: transition + 'TimingFunction',
|
19
|
+
END: transitionEnd,
|
20
|
+
|
21
|
+
// transition-property value to use with each particular custom property
|
22
|
+
CUSTOM_PROPS_PROPERTIES: {
|
23
|
+
position: L.Browser.webkit ? L.DomUtil.TRANSFORM : 'top, left'
|
24
|
+
}
|
25
|
+
};
|
26
|
+
}()),
|
27
|
+
|
28
|
+
options: {
|
29
|
+
fakeStepInterval: 100
|
30
|
+
},
|
31
|
+
|
32
|
+
initialize: function (/*HTMLElement*/ el, /*Object*/ options) {
|
33
|
+
this._el = el;
|
34
|
+
L.Util.setOptions(this, options);
|
35
|
+
|
36
|
+
L.DomEvent.addListener(el, L.Transition.END, this._onTransitionEnd, this);
|
37
|
+
this._onFakeStep = L.Util.bind(this._onFakeStep, this);
|
38
|
+
},
|
39
|
+
|
40
|
+
run: function (/*Object*/ props) {
|
41
|
+
var prop,
|
42
|
+
propsList = [],
|
43
|
+
customProp = L.Transition.CUSTOM_PROPS_PROPERTIES;
|
44
|
+
|
45
|
+
for (prop in props) {
|
46
|
+
if (props.hasOwnProperty(prop)) {
|
47
|
+
prop = customProp[prop] ? customProp[prop] : prop;
|
48
|
+
prop = this._dasherize(prop);
|
49
|
+
propsList.push(prop);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
this._el.style[L.Transition.DURATION] = this.options.duration + 's';
|
54
|
+
this._el.style[L.Transition.EASING] = this.options.easing;
|
55
|
+
this._el.style[L.Transition.PROPERTY] = propsList.join(', ');
|
56
|
+
|
57
|
+
for (prop in props) {
|
58
|
+
if (props.hasOwnProperty(prop)) {
|
59
|
+
this._setProperty(prop, props[prop]);
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
this._inProgress = true;
|
64
|
+
|
65
|
+
this.fire('start');
|
66
|
+
|
67
|
+
if (L.Transition.NATIVE) {
|
68
|
+
clearInterval(this._timer);
|
69
|
+
this._timer = setInterval(this._onFakeStep, this.options.fakeStepInterval);
|
70
|
+
} else {
|
71
|
+
this._onTransitionEnd();
|
72
|
+
}
|
73
|
+
},
|
74
|
+
|
75
|
+
_dasherize: (function () {
|
76
|
+
var re = /([A-Z])/g;
|
77
|
+
|
78
|
+
function replaceFn(w) {
|
79
|
+
return '-' + w.toLowerCase();
|
80
|
+
}
|
81
|
+
|
82
|
+
return function (str) {
|
83
|
+
return str.replace(re, replaceFn);
|
84
|
+
};
|
85
|
+
}()),
|
86
|
+
|
87
|
+
_onFakeStep: function () {
|
88
|
+
this.fire('step');
|
89
|
+
},
|
90
|
+
|
91
|
+
_onTransitionEnd: function () {
|
92
|
+
if (this._inProgress) {
|
93
|
+
this._inProgress = false;
|
94
|
+
clearInterval(this._timer);
|
95
|
+
|
96
|
+
this._el.style[L.Transition.PROPERTY] = 'none';
|
97
|
+
|
98
|
+
this.fire('step');
|
99
|
+
this.fire('end');
|
100
|
+
}
|
101
|
+
}
|
102
|
+
});
|
@@ -0,0 +1,126 @@
|
|
1
|
+
/*
|
2
|
+
* L.Transition fallback implementation that powers Leaflet animation
|
3
|
+
* in browsers that don't support CSS3 Transitions
|
4
|
+
*/
|
5
|
+
|
6
|
+
L.Transition = L.Transition.NATIVE ? L.Transition : L.Transition.extend({
|
7
|
+
statics: {
|
8
|
+
getTime: Date.now || function () {
|
9
|
+
return +new Date();
|
10
|
+
},
|
11
|
+
|
12
|
+
TIMER: true,
|
13
|
+
|
14
|
+
EASINGS: {
|
15
|
+
'ease': [0.25, 0.1, 0.25, 1.0],
|
16
|
+
'linear': [0.0, 0.0, 1.0, 1.0],
|
17
|
+
'ease-in': [0.42, 0, 1.0, 1.0],
|
18
|
+
'ease-out': [0, 0, 0.58, 1.0],
|
19
|
+
'ease-in-out': [0.42, 0, 0.58, 1.0]
|
20
|
+
},
|
21
|
+
|
22
|
+
CUSTOM_PROPS_GETTERS: {
|
23
|
+
position: L.DomUtil.getPosition
|
24
|
+
},
|
25
|
+
|
26
|
+
//used to get units from strings like "10.5px" (->px)
|
27
|
+
UNIT_RE: /^[\d\.]+(\D*)$/
|
28
|
+
},
|
29
|
+
|
30
|
+
options: {
|
31
|
+
fps: 50
|
32
|
+
},
|
33
|
+
|
34
|
+
initialize: function (el, options) {
|
35
|
+
this._el = el;
|
36
|
+
L.Util.extend(this.options, options);
|
37
|
+
|
38
|
+
var easings = L.Transition.EASINGS[this.options.easing] || L.Transition.EASINGS.ease;
|
39
|
+
|
40
|
+
this._p1 = new L.Point(0, 0);
|
41
|
+
this._p2 = new L.Point(easings[0], easings[1]);
|
42
|
+
this._p3 = new L.Point(easings[2], easings[3]);
|
43
|
+
this._p4 = new L.Point(1, 1);
|
44
|
+
|
45
|
+
this._step = L.Util.bind(this._step, this);
|
46
|
+
this._interval = Math.round(1000 / this.options.fps);
|
47
|
+
},
|
48
|
+
|
49
|
+
run: function (props) {
|
50
|
+
this._props = {};
|
51
|
+
|
52
|
+
var getters = L.Transition.CUSTOM_PROPS_GETTERS,
|
53
|
+
re = L.Transition.UNIT_RE;
|
54
|
+
|
55
|
+
this.fire('start');
|
56
|
+
|
57
|
+
for (var prop in props) {
|
58
|
+
if (props.hasOwnProperty(prop)) {
|
59
|
+
var p = {};
|
60
|
+
if (prop in getters) {
|
61
|
+
p.from = getters[prop](this._el);
|
62
|
+
} else {
|
63
|
+
var matches = this._el.style[prop].match(re);
|
64
|
+
p.from = parseFloat(matches[0]);
|
65
|
+
p.unit = matches[1];
|
66
|
+
}
|
67
|
+
p.to = props[prop];
|
68
|
+
this._props[prop] = p;
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
clearInterval(this._timer);
|
73
|
+
this._timer = setInterval(this._step, this._interval);
|
74
|
+
this._startTime = L.Transition.getTime();
|
75
|
+
},
|
76
|
+
|
77
|
+
_step: function () {
|
78
|
+
var time = L.Transition.getTime(),
|
79
|
+
elapsed = time - this._startTime,
|
80
|
+
duration = this.options.duration * 1000;
|
81
|
+
|
82
|
+
if (elapsed < duration) {
|
83
|
+
this._runFrame(this._cubicBezier(elapsed / duration));
|
84
|
+
} else {
|
85
|
+
this._runFrame(1);
|
86
|
+
this._complete();
|
87
|
+
}
|
88
|
+
},
|
89
|
+
|
90
|
+
_runFrame: function (percentComplete) {
|
91
|
+
var setters = L.Transition.CUSTOM_PROPS_SETTERS,
|
92
|
+
prop, p, value;
|
93
|
+
|
94
|
+
for (prop in this._props) {
|
95
|
+
if (this._props.hasOwnProperty(prop)) {
|
96
|
+
p = this._props[prop];
|
97
|
+
if (prop in setters) {
|
98
|
+
value = p.to.subtract(p.from).multiplyBy(percentComplete).add(p.from);
|
99
|
+
setters[prop](this._el, value);
|
100
|
+
} else {
|
101
|
+
this._el.style[prop] =
|
102
|
+
((p.to - p.from) * percentComplete + p.from) + p.unit;
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
this.fire('step');
|
107
|
+
},
|
108
|
+
|
109
|
+
_complete: function () {
|
110
|
+
clearInterval(this._timer);
|
111
|
+
this.fire('end');
|
112
|
+
},
|
113
|
+
|
114
|
+
_cubicBezier: function (t) {
|
115
|
+
var a = Math.pow(1 - t, 3),
|
116
|
+
b = 3 * Math.pow(1 - t, 2) * t,
|
117
|
+
c = 3 * (1 - t) * Math.pow(t, 2),
|
118
|
+
d = Math.pow(t, 3),
|
119
|
+
p1 = this._p1.multiplyBy(a),
|
120
|
+
p2 = this._p2.multiplyBy(b),
|
121
|
+
p3 = this._p3.multiplyBy(c),
|
122
|
+
p4 = this._p4.multiplyBy(d);
|
123
|
+
|
124
|
+
return p1.add(p2).add(p3).add(p4).y;
|
125
|
+
}
|
126
|
+
});
|
@@ -0,0 +1,28 @@
|
|
1
|
+
L.Transition = L.Class.extend({
|
2
|
+
includes: L.Mixin.Events,
|
3
|
+
|
4
|
+
statics: {
|
5
|
+
CUSTOM_PROPS_SETTERS: {
|
6
|
+
position: L.DomUtil.setPosition
|
7
|
+
//TODO transform custom attr
|
8
|
+
},
|
9
|
+
|
10
|
+
implemented: function () {
|
11
|
+
return L.Transition.NATIVE || L.Transition.TIMER;
|
12
|
+
}
|
13
|
+
},
|
14
|
+
|
15
|
+
options: {
|
16
|
+
easing: 'ease',
|
17
|
+
duration: 0.5
|
18
|
+
},
|
19
|
+
|
20
|
+
_setProperty: function (prop, value) {
|
21
|
+
var setters = L.Transition.CUSTOM_PROPS_SETTERS;
|
22
|
+
if (prop in setters) {
|
23
|
+
setters[prop](this._el, value);
|
24
|
+
} else {
|
25
|
+
this._el.style[prop] = value;
|
26
|
+
}
|
27
|
+
}
|
28
|
+
});
|
@@ -0,0 +1,44 @@
|
|
1
|
+
/*
|
2
|
+
CM.LatLng represents a geographical point with latitude and longtitude coordinates.
|
3
|
+
*/
|
4
|
+
|
5
|
+
L.LatLng = function (/*Number*/ rawLat, /*Number*/ rawLng, /*Boolean*/ noWrap) {
|
6
|
+
var lat = parseFloat(rawLat),
|
7
|
+
lng = parseFloat(rawLng);
|
8
|
+
|
9
|
+
if (isNaN(lat) || isNaN(lng)) {
|
10
|
+
throw new Error('Invalid LatLng object: (' + rawLat + ', ' + rawLng + ')');
|
11
|
+
}
|
12
|
+
|
13
|
+
if (noWrap !== true) {
|
14
|
+
lat = Math.max(Math.min(lat, 90), -90); // clamp latitude into -90..90
|
15
|
+
lng = (lng + 180) % 360 + ((lng < -180 || lng === 180) ? 180 : -180); // wrap longtitude into -180..180
|
16
|
+
}
|
17
|
+
|
18
|
+
//TODO change to lat() & lng()
|
19
|
+
this.lat = lat;
|
20
|
+
this.lng = lng;
|
21
|
+
};
|
22
|
+
|
23
|
+
L.Util.extend(L.LatLng, {
|
24
|
+
DEG_TO_RAD: Math.PI / 180,
|
25
|
+
RAD_TO_DEG: 180 / Math.PI,
|
26
|
+
MAX_MARGIN: 1.0E-9 // max margin of error for the "equals" check
|
27
|
+
});
|
28
|
+
|
29
|
+
L.LatLng.prototype = {
|
30
|
+
equals: function (/*LatLng*/ obj) {
|
31
|
+
if (!(obj instanceof L.LatLng)) {
|
32
|
+
return false;
|
33
|
+
}
|
34
|
+
|
35
|
+
var margin = Math.max(Math.abs(this.lat - obj.lat), Math.abs(this.lng - obj.lng));
|
36
|
+
return margin <= L.LatLng.MAX_MARGIN;
|
37
|
+
},
|
38
|
+
|
39
|
+
toString: function () {
|
40
|
+
return 'LatLng(' +
|
41
|
+
L.Util.formatNum(this.lat) + ', ' +
|
42
|
+
L.Util.formatNum(this.lng) + ')';
|
43
|
+
}
|
44
|
+
};
|
@@ -0,0 +1,86 @@
|
|
1
|
+
/*
|
2
|
+
* L.LatLngBounds represents a rectangular area on the map in geographical coordinates.
|
3
|
+
*/
|
4
|
+
|
5
|
+
L.LatLngBounds = L.Class.extend({
|
6
|
+
initialize: function (southWest, northEast) { // (LatLng, LatLng) or (LatLng[])
|
7
|
+
if (!southWest) {
|
8
|
+
return;
|
9
|
+
}
|
10
|
+
var latlngs = (southWest instanceof Array ? southWest : [southWest, northEast]);
|
11
|
+
for (var i = 0, len = latlngs.length; i < len; i++) {
|
12
|
+
this.extend(latlngs[i]);
|
13
|
+
}
|
14
|
+
},
|
15
|
+
|
16
|
+
// extend the bounds to contain the given point
|
17
|
+
extend: function (/*LatLng*/ latlng) {
|
18
|
+
if (!this._southWest && !this._northEast) {
|
19
|
+
this._southWest = new L.LatLng(latlng.lat, latlng.lng, true);
|
20
|
+
this._northEast = new L.LatLng(latlng.lat, latlng.lng, true);
|
21
|
+
} else {
|
22
|
+
this._southWest.lat = Math.min(latlng.lat, this._southWest.lat);
|
23
|
+
this._southWest.lng = Math.min(latlng.lng, this._southWest.lng);
|
24
|
+
this._northEast.lat = Math.max(latlng.lat, this._northEast.lat);
|
25
|
+
this._northEast.lng = Math.max(latlng.lng, this._northEast.lng);
|
26
|
+
}
|
27
|
+
},
|
28
|
+
|
29
|
+
getCenter: function () /*-> LatLng*/ {
|
30
|
+
return new L.LatLng(
|
31
|
+
(this._southWest.lat + this._northEast.lat) / 2,
|
32
|
+
(this._southWest.lng + this._northEast.lng) / 2);
|
33
|
+
},
|
34
|
+
|
35
|
+
getSouthWest: function () {
|
36
|
+
return this._southWest;
|
37
|
+
},
|
38
|
+
|
39
|
+
getNorthEast: function () {
|
40
|
+
return this._northEast;
|
41
|
+
},
|
42
|
+
|
43
|
+
getNorthWest: function () {
|
44
|
+
return new L.LatLng(this._northEast.lat, this._southWest.lng, true);
|
45
|
+
},
|
46
|
+
|
47
|
+
getSouthEast: function () {
|
48
|
+
return new L.LatLng(this._southWest.lat, this._northEast.lng, true);
|
49
|
+
},
|
50
|
+
|
51
|
+
contains: function (/*LatLngBounds or LatLng*/ obj) /*-> Boolean*/ {
|
52
|
+
var sw = this._southWest,
|
53
|
+
ne = this._northEast,
|
54
|
+
sw2, ne2;
|
55
|
+
|
56
|
+
if (obj instanceof L.LatLngBounds) {
|
57
|
+
sw2 = obj.getSouthWest();
|
58
|
+
ne2 = obj.getNorthEast();
|
59
|
+
} else {
|
60
|
+
sw2 = ne2 = obj;
|
61
|
+
}
|
62
|
+
|
63
|
+
return (sw2.lat >= sw.lat) && (ne2.lat <= ne.lat) &&
|
64
|
+
(sw2.lng >= sw.lng) && (ne2.lng <= ne.lng);
|
65
|
+
},
|
66
|
+
|
67
|
+
intersects: function (/*LatLngBounds*/ bounds) {
|
68
|
+
var sw = this._southWest,
|
69
|
+
ne = this._northEast,
|
70
|
+
sw2 = bounds.getSouthWest(),
|
71
|
+
ne2 = bounds.getNorthEast();
|
72
|
+
|
73
|
+
var latIntersects = (ne2.lat >= sw.lat) && (sw2.lat <= ne.lat),
|
74
|
+
lngIntersects = (ne2.lng >= sw.lng) && (sw2.lng <= ne.lng);
|
75
|
+
|
76
|
+
return latIntersects && lngIntersects;
|
77
|
+
},
|
78
|
+
|
79
|
+
toBBoxString: function () {
|
80
|
+
var sw = this._southWest,
|
81
|
+
ne = this._northEast;
|
82
|
+
return [sw.lng, sw.lat, ne.lng, ne.lat].join(',');
|
83
|
+
}
|
84
|
+
});
|
85
|
+
|
86
|
+
//TODO International date line?
|
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
L.CRS.EPSG3395 = L.Util.extend({}, L.CRS, {
|
3
|
+
code: 'EPSG:3395',
|
4
|
+
|
5
|
+
projection: L.Projection.Mercator,
|
6
|
+
transformation: (function () {
|
7
|
+
var m = L.Projection.Mercator,
|
8
|
+
r = m.R_MAJOR,
|
9
|
+
r2 = m.R_MINOR;
|
10
|
+
|
11
|
+
return new L.Transformation(0.5 / (Math.PI * r), 0.5, -0.5 / (Math.PI * r2), 0.5);
|
12
|
+
}())
|
13
|
+
});
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
L.CRS.EPSG3857 = L.Util.extend({}, L.CRS, {
|
3
|
+
code: 'EPSG:3857',
|
4
|
+
|
5
|
+
projection: L.Projection.SphericalMercator,
|
6
|
+
transformation: new L.Transformation(0.5 / Math.PI, 0.5, -0.5 / Math.PI, 0.5),
|
7
|
+
|
8
|
+
project: function (/*LatLng*/ latlng)/*-> Point*/ {
|
9
|
+
var projectedPoint = this.projection.project(latlng),
|
10
|
+
earthRadius = 6378137;
|
11
|
+
return projectedPoint.multiplyBy(earthRadius);
|
12
|
+
}
|
13
|
+
});
|
14
|
+
|
15
|
+
L.CRS.EPSG900913 = L.Util.extend({}, L.CRS.EPSG3857, {
|
16
|
+
code: 'EPSG:900913'
|
17
|
+
});
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
L.CRS = {
|
3
|
+
latLngToPoint: function (/*LatLng*/ latlng, /*Number*/ scale)/*-> Point*/ {
|
4
|
+
var projectedPoint = this.projection.project(latlng);
|
5
|
+
return this.transformation._transform(projectedPoint, scale);
|
6
|
+
},
|
7
|
+
|
8
|
+
pointToLatLng: function (/*Point*/ point, /*Number*/ scale, /*(optional) Boolean*/ unbounded)/*-> LatLng*/ {
|
9
|
+
var untransformedPoint = this.transformation.untransform(point, scale);
|
10
|
+
return this.projection.unproject(untransformedPoint, unbounded);
|
11
|
+
//TODO get rid of 'unbounded' everywhere
|
12
|
+
},
|
13
|
+
|
14
|
+
project: function (latlng) {
|
15
|
+
return this.projection.project(latlng);
|
16
|
+
}
|
17
|
+
};
|