leaflet-ruby 0.3.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. data/CHANGELOG.rdoc +5 -0
  2. data/LICENSE +21 -0
  3. data/README.rdoc +55 -0
  4. data/Rakefile +15 -0
  5. data/leaflet-ruby.gemspec +24 -0
  6. data/lib/leaflet-ruby.rb +18 -0
  7. data/lib/leaflet/CHANGELOG.md +181 -0
  8. data/lib/leaflet/Jakefile.js +65 -0
  9. data/lib/leaflet/LICENSE +22 -0
  10. data/lib/leaflet/README.md +32 -0
  11. data/lib/leaflet/build/build.html +243 -0
  12. data/lib/leaflet/build/build.js +79 -0
  13. data/lib/leaflet/build/deps.js +231 -0
  14. data/lib/leaflet/build/hint.js +30 -0
  15. data/lib/leaflet/build/hintrc.js +44 -0
  16. data/lib/leaflet/debug/control/control-layers.html +47 -0
  17. data/lib/leaflet/debug/control/map-control.html +29 -0
  18. data/lib/leaflet/debug/css/mobile.css +6 -0
  19. data/lib/leaflet/debug/css/screen.css +5 -0
  20. data/lib/leaflet/debug/geojson/geojson-sample.js +53 -0
  21. data/lib/leaflet/debug/geojson/geojson.html +56 -0
  22. data/lib/leaflet/debug/leaflet-include.js +120 -0
  23. data/lib/leaflet/debug/map/canvas.html +46 -0
  24. data/lib/leaflet/debug/map/map-mobile.html +42 -0
  25. data/lib/leaflet/debug/map/map.html +54 -0
  26. data/lib/leaflet/debug/map/max-bounds.html +36 -0
  27. data/lib/leaflet/debug/map/scroll.html +35 -0
  28. data/lib/leaflet/debug/map/wms-marble.html +30 -0
  29. data/lib/leaflet/debug/map/wms.html +37 -0
  30. data/lib/leaflet/debug/vector/editable.html +43 -0
  31. data/lib/leaflet/debug/vector/route.js +1 -0
  32. data/lib/leaflet/debug/vector/vector-bounds.html +69 -0
  33. data/lib/leaflet/debug/vector/vector-canvas.html +92 -0
  34. data/lib/leaflet/debug/vector/vector-mobile.html +38 -0
  35. data/lib/leaflet/debug/vector/vector-simple.html +63 -0
  36. data/lib/leaflet/debug/vector/vector.html +38 -0
  37. data/lib/leaflet/dist/images/layers.png +0 -0
  38. data/lib/leaflet/dist/images/marker-shadow.png +0 -0
  39. data/lib/leaflet/dist/images/marker.png +0 -0
  40. data/lib/leaflet/dist/images/popup-close.png +0 -0
  41. data/lib/leaflet/dist/images/zoom-in.png +0 -0
  42. data/lib/leaflet/dist/images/zoom-out.png +0 -0
  43. data/lib/leaflet/dist/leaflet-src.js +5537 -0
  44. data/lib/leaflet/dist/leaflet.css +323 -0
  45. data/lib/leaflet/dist/leaflet.ie.css +48 -0
  46. data/lib/leaflet/dist/leaflet.js +6 -0
  47. data/lib/leaflet/lib/jasmine/jasmine-html.js +182 -0
  48. data/lib/leaflet/lib/jasmine/jasmine.css +166 -0
  49. data/lib/leaflet/lib/jasmine/jasmine.js +2421 -0
  50. data/lib/leaflet/spec/runner.html +57 -0
  51. data/lib/leaflet/spec/suites/LeafletSpec.js +15 -0
  52. data/lib/leaflet/spec/suites/SpecHelper.js +28 -0
  53. data/lib/leaflet/spec/suites/core/ClassSpec.js +153 -0
  54. data/lib/leaflet/spec/suites/core/EventsSpec.js +110 -0
  55. data/lib/leaflet/spec/suites/core/UtilSpec.js +63 -0
  56. data/lib/leaflet/spec/suites/dom/DomEventSpec.js +102 -0
  57. data/lib/leaflet/spec/suites/dom/DomUtilSpec.js +59 -0
  58. data/lib/leaflet/spec/suites/geo/LatLngBoundsSpec.js +1 -0
  59. data/lib/leaflet/spec/suites/geo/LatLngSpec.js +76 -0
  60. data/lib/leaflet/spec/suites/geo/ProjectionSpec.js +42 -0
  61. data/lib/leaflet/spec/suites/geometry/BoundsSpec.js +53 -0
  62. data/lib/leaflet/spec/suites/geometry/PointSpec.js +45 -0
  63. data/lib/leaflet/spec/suites/geometry/TransformationSpec.js +19 -0
  64. data/lib/leaflet/spec/suites/layer/TileLayerSpec.js +1 -0
  65. data/lib/leaflet/spec/suites/layer/vector/PolylineGeometrySpec.js +35 -0
  66. data/lib/leaflet/spec/suites/map/MapSpec.js +1 -0
  67. data/lib/leaflet/src/Leaflet.js +33 -0
  68. data/lib/leaflet/src/control/Control.Attribution.js +66 -0
  69. data/lib/leaflet/src/control/Control.Layers.js +167 -0
  70. data/lib/leaflet/src/control/Control.Zoom.js +36 -0
  71. data/lib/leaflet/src/control/Control.js +9 -0
  72. data/lib/leaflet/src/core/Browser.js +53 -0
  73. data/lib/leaflet/src/core/Class.js +66 -0
  74. data/lib/leaflet/src/core/Events.js +62 -0
  75. data/lib/leaflet/src/core/Handler.js +29 -0
  76. data/lib/leaflet/src/core/Util.js +108 -0
  77. data/lib/leaflet/src/dom/DomEvent.DoubleTap.js +43 -0
  78. data/lib/leaflet/src/dom/DomEvent.js +154 -0
  79. data/lib/leaflet/src/dom/DomUtil.js +155 -0
  80. data/lib/leaflet/src/dom/Draggable.js +147 -0
  81. data/lib/leaflet/src/dom/transition/Transition.Native.js +102 -0
  82. data/lib/leaflet/src/dom/transition/Transition.Timer.js +126 -0
  83. data/lib/leaflet/src/dom/transition/Transition.js +28 -0
  84. data/lib/leaflet/src/geo/LatLng.js +44 -0
  85. data/lib/leaflet/src/geo/LatLngBounds.js +86 -0
  86. data/lib/leaflet/src/geo/crs/CRS.EPSG3395.js +13 -0
  87. data/lib/leaflet/src/geo/crs/CRS.EPSG3857.js +17 -0
  88. data/lib/leaflet/src/geo/crs/CRS.EPSG4326.js +7 -0
  89. data/lib/leaflet/src/geo/crs/CRS.js +17 -0
  90. data/lib/leaflet/src/geo/projection/Projection.LonLat.js +10 -0
  91. data/lib/leaflet/src/geo/projection/Projection.Mercator.js +51 -0
  92. data/lib/leaflet/src/geo/projection/Projection.SphericalMercator.js +23 -0
  93. data/lib/leaflet/src/geo/projection/Projection.js +5 -0
  94. data/lib/leaflet/src/geometry/Bounds.js +50 -0
  95. data/lib/leaflet/src/geometry/LineUtil.js +194 -0
  96. data/lib/leaflet/src/geometry/Point.js +66 -0
  97. data/lib/leaflet/src/geometry/PolyUtil.js +59 -0
  98. data/lib/leaflet/src/geometry/Transformation.js +31 -0
  99. data/lib/leaflet/src/layer/FeatureGroup.js +40 -0
  100. data/lib/leaflet/src/layer/GeoJSON.js +104 -0
  101. data/lib/leaflet/src/layer/ImageOverlay.js +58 -0
  102. data/lib/leaflet/src/layer/LayerGroup.js +74 -0
  103. data/lib/leaflet/src/layer/Popup.js +179 -0
  104. data/lib/leaflet/src/layer/marker/Icon.js +58 -0
  105. data/lib/leaflet/src/layer/marker/Marker.Drag.js +57 -0
  106. data/lib/leaflet/src/layer/marker/Marker.Popup.js +42 -0
  107. data/lib/leaflet/src/layer/marker/Marker.js +142 -0
  108. data/lib/leaflet/src/layer/tile/TileLayer.Canvas.js +41 -0
  109. data/lib/leaflet/src/layer/tile/TileLayer.WMS.js +47 -0
  110. data/lib/leaflet/src/layer/tile/TileLayer.js +310 -0
  111. data/lib/leaflet/src/layer/vector/Circle.js +68 -0
  112. data/lib/leaflet/src/layer/vector/CircleMarker.js +25 -0
  113. data/lib/leaflet/src/layer/vector/MultiPoly.js +34 -0
  114. data/lib/leaflet/src/layer/vector/Path.Popup.js +24 -0
  115. data/lib/leaflet/src/layer/vector/Path.SVG.js +138 -0
  116. data/lib/leaflet/src/layer/vector/Path.VML.js +93 -0
  117. data/lib/leaflet/src/layer/vector/Path.js +88 -0
  118. data/lib/leaflet/src/layer/vector/Polygon.js +64 -0
  119. data/lib/leaflet/src/layer/vector/Polyline.js +146 -0
  120. data/lib/leaflet/src/layer/vector/canvas/Circle.Canvas.js +18 -0
  121. data/lib/leaflet/src/layer/vector/canvas/Path.Canvas.js +146 -0
  122. data/lib/leaflet/src/layer/vector/canvas/Polygon.Canvas.js +34 -0
  123. data/lib/leaflet/src/layer/vector/canvas/Polyline.Canvas.js +27 -0
  124. data/lib/leaflet/src/map/Map.js +613 -0
  125. data/lib/leaflet/src/map/anim/Map.PanAnimation.js +70 -0
  126. data/lib/leaflet/src/map/anim/Map.ZoomAnimation.js +133 -0
  127. data/lib/leaflet/src/map/ext/Map.Control.js +50 -0
  128. data/lib/leaflet/src/map/ext/Map.Geolocation.js +86 -0
  129. data/lib/leaflet/src/map/ext/Map.Popup.js +20 -0
  130. data/lib/leaflet/src/map/handler/Map.BoxZoom.js +73 -0
  131. data/lib/leaflet/src/map/handler/Map.DoubleClickZoom.js +18 -0
  132. data/lib/leaflet/src/map/handler/Map.Drag.js +81 -0
  133. data/lib/leaflet/src/map/handler/Map.ScrollWheelZoom.js +55 -0
  134. data/lib/leaflet/src/map/handler/Map.TouchZoom.js +93 -0
  135. data/lib/zerista/CRS.Cartesian.js +20 -0
  136. data/lib/zerista/Projection.Identity.js +11 -0
  137. data/lib/zerista/zerista_layer.js +97 -0
  138. data/vendor/assets/javascripts/leaflet.js +139 -0
  139. data/vendor/assets/stylesheets/leaflet.css +1 -0
  140. data/vendor/assets/stylesheets/leaflet.ie.css +1 -0
  141. metadata +185 -0
@@ -0,0 +1,59 @@
1
+ describe('DomUtil', function() {
2
+ var el;
3
+
4
+ beforeEach(function() {
5
+ el = document.createElement('div');
6
+ el.style.position = 'absolute';
7
+ el.style.top = el.style.left = '-10000px';
8
+ document.body.appendChild(el);
9
+ });
10
+
11
+ afterEach(function() {
12
+ document.body.removeChild(el);
13
+ });
14
+
15
+ describe('#get', function() {
16
+ it('should get element by id if the given argument is string', function() {
17
+ el.id = 'testId';
18
+ expect(L.DomUtil.get(el.id)).toBe(el);
19
+ });
20
+
21
+ it('should return the element if it is given as an argument', function() {
22
+ expect(L.DomUtil.get(el)).toBe(el);
23
+ });
24
+ });
25
+
26
+ describe('#addClass, #removeClass, #hasClass', function() {
27
+ it('should has defined class for test element', function() {
28
+ el.className = 'bar foo baz ';
29
+ expect(L.DomUtil.hasClass(el, 'foo')).toBeTruthy();
30
+ expect(L.DomUtil.hasClass(el, 'bar')).toBeTruthy();
31
+ expect(L.DomUtil.hasClass(el, 'baz')).toBeTruthy();
32
+ expect(L.DomUtil.hasClass(el, 'boo')).toBeFalsy();
33
+ });
34
+
35
+ it('should properly addClass and removeClass for element', function() {
36
+ el.className = '';
37
+ L.DomUtil.addClass(el, 'foo');
38
+
39
+ expect(el.className).toEqual('foo');
40
+ expect(L.DomUtil.hasClass(el, 'foo')).toBeTruthy();
41
+
42
+ L.DomUtil.addClass(el, 'bar');
43
+ expect(el.className).toEqual('foo bar');
44
+ expect(L.DomUtil.hasClass(el, 'foo')).toBeTruthy();
45
+
46
+ L.DomUtil.removeClass(el, 'foo');
47
+ expect(el.className).toEqual('bar');
48
+ expect(L.DomUtil.hasClass(el, 'foo')).toBeFalsy();
49
+
50
+ el.className = 'foo bar barz';
51
+ L.DomUtil.removeClass(el, 'bar');
52
+ expect(el.className).toEqual('foo barz');
53
+ })
54
+ });
55
+
56
+ describe('#setPosition', noSpecs);
57
+
58
+ describe('#getStyle', noSpecs);
59
+ });
@@ -0,0 +1 @@
1
+ describe('LatLngBounds', noSpecs);
@@ -0,0 +1,76 @@
1
+ describe('LatLng', function() {
2
+ describe('constructor', function() {
3
+ it("should set lat and lng", function() {
4
+ var a = new L.LatLng(25, 74);
5
+ expect(a.lat).toEqual(25);
6
+ expect(a.lng).toEqual(74);
7
+
8
+ var a = new L.LatLng(-25, -74);
9
+ expect(a.lat).toEqual(-25);
10
+ expect(a.lng).toEqual(-74);
11
+ });
12
+
13
+ it("should clamp latitude to lie between -90 and 90", function() {
14
+ var a = new L.LatLng(150, 0).lat;
15
+ expect(a).toEqual(90);
16
+
17
+ var b = new L.LatLng(-230, 0).lat;
18
+ expect(b).toEqual(-90);
19
+ });
20
+
21
+ it("should clamp longtitude to lie between -180 and 180", function() {
22
+ var a = new L.LatLng(0, 190).lng;
23
+ expect(a).toEqual(-170);
24
+
25
+ var b = new L.LatLng(0, 360).lng;
26
+ expect(b).toEqual(0);
27
+
28
+ var c = new L.LatLng(0, 380).lng;
29
+ expect(c).toEqual(20);
30
+
31
+ var d = new L.LatLng(0, -190).lng;
32
+ expect(d).toEqual(170);
33
+
34
+ var e = new L.LatLng(0, -360).lng;
35
+ expect(e).toEqual(0);
36
+
37
+ var f = new L.LatLng(0, -380).lng;
38
+ expect(f).toEqual(-20);
39
+
40
+ var g = new L.LatLng(0, 90).lng;
41
+ expect(g).toEqual(90);
42
+
43
+ var h = new L.LatLng(0, 180).lng;
44
+ expect(h).toEqual(180);
45
+ });
46
+
47
+ it("should not clamp latitude and longtitude if unbounded flag set to true", function() {
48
+ var a = new L.LatLng(150, 0, true).lat;
49
+ expect(a).toEqual(150);
50
+
51
+ var b = new L.LatLng(-230, 0, true).lat;
52
+ expect(b).toEqual(-230);
53
+
54
+ var c = new L.LatLng(0, 250, true).lng;
55
+ expect(c).toEqual(250);
56
+
57
+ var d = new L.LatLng(0, -190, true).lng;
58
+ expect(d).toEqual(-190);
59
+ });
60
+ });
61
+
62
+ describe('#equals', function() {
63
+ it("should return true if compared objects are equal within a certain margin", function() {
64
+ var a = new L.LatLng(10, 20);
65
+ var b = new L.LatLng(10 + 1.0E-10, 20 - 1.0E-10);
66
+ expect(a.equals(b)).toBe(true);
67
+ });
68
+
69
+ it("should return false if compared objects are not equal within a certain margin", function() {
70
+ var a = new L.LatLng(10, 20);
71
+ var b = new L.LatLng(10, 23.3);
72
+ expect(a.equals(b)).toBe(false);
73
+ });
74
+ });
75
+ });
76
+
@@ -0,0 +1,42 @@
1
+ xdescribe("Projection.Mercator", function() {
2
+ var p = L.Projection.Mercator;
3
+
4
+ beforeEach(function() {
5
+ function almostEqual(a, b, p) {
6
+ return Math.abs(a - b) <= (p || 1.0E-12);
7
+ };
8
+ this.addMatchers({
9
+ toAlmostEqual: function(expected, margin) {
10
+ var p1 = this.actual,
11
+ p2 = expected;
12
+ return almostEqual(p1.x, p2.x, margin) && almostEqual(p1.y, p2.y, margin);
13
+ }
14
+ });
15
+ });
16
+
17
+
18
+ describe("#project", function() {
19
+ it("should do projection properly", function() {
20
+ //edge cases
21
+ expect(p.project(new L.LatLng(0, 0))).toAlmostEqual(new L.Point(0, 0));
22
+ expect(p.project(new L.LatLng(90, 180))).toAlmostEqual(new L.Point(-Math.PI, Math.PI));
23
+ expect(p.project(new L.LatLng(-90, -180))).toAlmostEqual(new L.Point(-Math.PI, -Math.PI));
24
+
25
+ expect(p.project(new L.LatLng(50, 30))).toAlmostEqual(new L.Point(0.523598775598, 1.010683188683));
26
+ });
27
+ });
28
+
29
+ describe("#unproject", function() {
30
+ it("should do unprojection properly", function() {
31
+ function pr(point) {
32
+ return p.project(p.unproject(point));
33
+ }
34
+
35
+ expect(pr(new L.Point(0, 0))).toAlmostEqual(new L.Point(0, 0));
36
+ expect(pr(new L.Point(-Math.PI, Math.PI))).toAlmostEqual(new L.Point(-Math.PI, Math.PI));
37
+ expect(pr(new L.Point(-Math.PI, -Math.PI))).toAlmostEqual(new L.Point(-Math.PI, -Math.PI));
38
+
39
+ expect(pr(new L.Point(0.523598775598, 1.010683188683))).toAlmostEqual(new L.Point(0.523598775598, 1.010683188683));
40
+ });
41
+ });
42
+ });
@@ -0,0 +1,53 @@
1
+ describe('Bounds', function() {
2
+ var a, b;
3
+
4
+ beforeEach(function() {
5
+ a = new L.Bounds(
6
+ new L.Point(14, 12),
7
+ new L.Point(30, 40));
8
+ b = new L.Bounds([
9
+ new L.Point(20, 12),
10
+ new L.Point(14, 20),
11
+ new L.Point(30, 40)
12
+ ]);
13
+ });
14
+
15
+ describe('constructor', function() {
16
+ it('should create bounds with proper min & max on (Point, Point)', function() {
17
+ expect(a.min).toEqual(new L.Point(14, 12));
18
+ expect(a.max).toEqual(new L.Point(30, 40));
19
+ });
20
+ it('should create bounds with proper min & max on (Point[])', function() {
21
+ expect(b.min).toEqual(new L.Point(14, 12));
22
+ expect(b.max).toEqual(new L.Point(30, 40));
23
+ });
24
+ });
25
+
26
+ describe('#extend', function() {
27
+ it('should extend the bounds to contain the given point', function() {
28
+ a.extend(new L.Point(50, 20));
29
+ expect(a.min).toEqual(new L.Point(14, 12));
30
+ expect(a.max).toEqual(new L.Point(50, 40));
31
+
32
+ b.extend(new L.Point(25, 50));
33
+ expect(b.min).toEqual(new L.Point(14, 12));
34
+ expect(b.max).toEqual(new L.Point(30, 50));
35
+ });
36
+ });
37
+
38
+ describe('#getCenter', function() {
39
+ it('should return the center point', function() {
40
+ expect(a.getCenter()).toEqual(new L.Point(22, 26));
41
+ });
42
+ });
43
+
44
+ describe('#contains', function() {
45
+ it('should contains other bounds or point', function() {
46
+ a.extend(new L.Point(50, 10));
47
+ expect(a.contains(b)).toBeTruthy();
48
+ expect(b.contains(a)).toBeFalsy();
49
+ expect(a.contains(new L.Point(24, 25))).toBeTruthy();
50
+ expect(a.contains(new L.Point(54, 65))).toBeFalsy();
51
+ });
52
+ });
53
+ });
@@ -0,0 +1,45 @@
1
+ describe("Point", function() {
2
+
3
+ describe('constructor', function() {
4
+
5
+ it("should create a point with the given x and y", function() {
6
+ var p = new L.Point(1.5, 2.5);
7
+ expect(p.x).toEqual(1.5);
8
+ expect(p.y).toEqual(2.5);
9
+ });
10
+
11
+ it("should round the given x and y if the third argument is true", function() {
12
+ var p = new L.Point(1.3, 2.7, true);
13
+ expect(p.x).toEqual(1);
14
+ expect(p.y).toEqual(3);
15
+ });
16
+ });
17
+
18
+ describe('#subtract', function() {
19
+ it('should subtract the given point from this one', function() {
20
+ var a = new L.Point(50, 30),
21
+ b = new L.Point(20, 10);
22
+ expect(a.subtract(b)).toEqual(new L.Point(30, 20));
23
+ });
24
+ });
25
+
26
+ describe('#add', function() {
27
+ it('should add the given point to this one', function() {
28
+ expect(new L.Point(50, 30).add(new L.Point(20, 10))).toEqual(new L.Point(70, 40));
29
+ });
30
+ });
31
+
32
+ describe('#divideBy', function() {
33
+ it('should divide this point by the given amount', function() {
34
+ expect(new L.Point(50, 30).divideBy(5)).toEqual(new L.Point(10, 6));
35
+ });
36
+ });
37
+
38
+ describe('#multiplyBy', function() {
39
+ it('should multiply this point by the given amount', function() {
40
+ expect(new L.Point(50, 30).multiplyBy(2)).toEqual(new L.Point(100, 60));
41
+ });
42
+ });
43
+
44
+ describe('#distanceTo', noSpecs);
45
+ });
@@ -0,0 +1,19 @@
1
+ describe("Transformation", function() {
2
+ var t, p;
3
+
4
+ beforeEach(function() {
5
+ t = new L.Transformation(1, 2, 3, 4);
6
+ p = new L.Point(10, 20);
7
+ });
8
+
9
+ it("#transform should perform a transformation", function() {
10
+ var p2 = t.transform(p, 2);
11
+ expect(p2).toEqual(new L.Point(24, 128));
12
+ });
13
+
14
+ it("#untransform should perform a reverse transformation", function() {
15
+ var p2 = t.transform(p, 2);
16
+ var p3 = t.untransform(p2, 2);
17
+ expect(p3).toEqual(p);
18
+ });
19
+ });
@@ -0,0 +1 @@
1
+ describe('TileLayer', noSpecs);
@@ -0,0 +1,35 @@
1
+ describe('PolylineGeometry', function() {
2
+
3
+ var c = document.createElement('div');
4
+ c.style.width = '400px';
5
+ c.style.height = '400px';
6
+ var map = new L.Map(c);
7
+ map.setView(new L.LatLng(55.8, 37.6), 6);
8
+
9
+ describe("#distanceTo", function() {
10
+ it("should calculate correct distances to points", function() {
11
+ var p1 = map.latLngToLayerPoint(new L.LatLng(55.8, 37.6));
12
+ var p2 = map.latLngToLayerPoint(new L.LatLng(57.123076977278, 44.861962891635));
13
+ var latlngs = [[56.485503424111, 35.545556640339], [55.972522915346, 36.116845702918], [55.502459116923, 34.930322265253], [55.31534617509, 38.973291015816]]
14
+ .map(function(ll) {
15
+ return new L.LatLng(ll[0], ll[1]);
16
+ });
17
+ var polyline = new L.Polyline([], {
18
+ 'noClip': true
19
+ });
20
+ map.addLayer(polyline);
21
+
22
+ expect(polyline.closestLayerPoint(p1)).toEqual(null);
23
+
24
+ polyline.setLatLngs(latlngs);
25
+ var point = polyline.closestLayerPoint(p1);
26
+ expect(point).not.toEqual(null);
27
+ expect(point.distance).not.toEqual(Infinity);
28
+ expect(point.distance).not.toEqual(NaN);
29
+
30
+ var point2 = polyline.closestLayerPoint(p2);
31
+
32
+ expect(point.distance).toBeLessThan(point2.distance);
33
+ });
34
+ });
35
+ });
@@ -0,0 +1 @@
1
+ describe("Map", noSpecs);
@@ -0,0 +1,33 @@
1
+
2
+ (function (root) {
3
+ root.L = {
4
+ VERSION: '0.3',
5
+
6
+ ROOT_URL: root.L_ROOT_URL || (function () {
7
+ var scripts = document.getElementsByTagName('script'),
8
+ leafletRe = /\/?leaflet[\-\._]?([\w\-\._]*)\.js\??/;
9
+
10
+ var i, len, src, matches;
11
+
12
+ for (i = 0, len = scripts.length; i < len; i++) {
13
+ src = scripts[i].src;
14
+ matches = src.match(leafletRe);
15
+
16
+ if (matches) {
17
+ if (matches[1] === 'include') {
18
+ return '../../dist/';
19
+ }
20
+ return src.replace(leafletRe, '') + '/';
21
+ }
22
+ }
23
+ return '';
24
+ }()),
25
+
26
+ noConflict: function () {
27
+ root.L = this._originalL;
28
+ return this;
29
+ },
30
+
31
+ _originalL: root.L
32
+ };
33
+ }(this));
@@ -0,0 +1,66 @@
1
+ L.Control.Attribution = L.Class.extend({
2
+ initialize: function (prefix) {
3
+ this._prefix = prefix || 'Powered by <a href="http://leaflet.cloudmade.com">Leaflet</a>';
4
+ this._attributions = {};
5
+ },
6
+
7
+ onAdd: function (map) {
8
+ this._container = L.DomUtil.create('div', 'leaflet-control-attribution');
9
+ L.DomEvent.disableClickPropagation(this._container);
10
+ this._map = map;
11
+ this._update();
12
+ },
13
+
14
+ getPosition: function () {
15
+ return L.Control.Position.BOTTOM_RIGHT;
16
+ },
17
+
18
+ getContainer: function () {
19
+ return this._container;
20
+ },
21
+
22
+ setPrefix: function (prefix) {
23
+ this._prefix = prefix;
24
+ this._update();
25
+ },
26
+
27
+ addAttribution: function (text) {
28
+ if (!text) {
29
+ return;
30
+ }
31
+ this._attributions[text] = true;
32
+ this._update();
33
+ },
34
+
35
+ removeAttribution: function (text) {
36
+ if (!text) {
37
+ return;
38
+ }
39
+ delete this._attributions[text];
40
+ this._update();
41
+ },
42
+
43
+ _update: function () {
44
+ if (!this._map) {
45
+ return;
46
+ }
47
+
48
+ var attribs = [];
49
+
50
+ for (var i in this._attributions) {
51
+ if (this._attributions.hasOwnProperty(i)) {
52
+ attribs.push(i);
53
+ }
54
+ }
55
+
56
+ var prefixAndAttribs = [];
57
+ if (this._prefix) {
58
+ prefixAndAttribs.push(this._prefix);
59
+ }
60
+ if (attribs.length) {
61
+ prefixAndAttribs.push(attribs.join(', '));
62
+ }
63
+
64
+ this._container.innerHTML = prefixAndAttribs.join(' &mdash; ');
65
+ }
66
+ });