leaflet-js 0.6.beta4 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (226) hide show
  1. checksums.yaml +6 -14
  2. data/CHANGELOG.rdoc +3 -0
  3. data/leaflet-js.gemspec +2 -2
  4. data/lib/leaflet.draw/CHANGELOG.md +45 -0
  5. data/lib/leaflet.draw/README.md +70 -23
  6. data/lib/leaflet.draw/build/deps.js +1 -0
  7. data/lib/leaflet.draw/dist/images/spritesheet-2x.png +0 -0
  8. data/lib/leaflet.draw/dist/images/spritesheet.png +0 -0
  9. data/lib/leaflet.draw/dist/leaflet.draw-src.js +489 -136
  10. data/lib/leaflet.draw/dist/leaflet.draw.css +34 -2
  11. data/lib/leaflet.draw/dist/leaflet.draw.ie.css +5 -0
  12. data/lib/leaflet.draw/dist/leaflet.draw.js +2 -2
  13. data/lib/leaflet.draw/examples/basic.html +14 -7
  14. data/lib/leaflet.draw/examples/libs/images/layers-2x.png +0 -0
  15. data/lib/leaflet.draw/examples/libs/images/layers.png +0 -0
  16. data/lib/leaflet.draw/examples/libs/images/marker-icon-2x.png +0 -0
  17. data/lib/leaflet.draw/examples/libs/leaflet-src.js +1129 -608
  18. data/lib/leaflet.draw/examples/libs/leaflet.css +85 -66
  19. data/lib/leaflet.draw/package.json +2 -2
  20. data/lib/leaflet.draw/spec/suites/DrawControlSpec.js +1 -1
  21. data/lib/leaflet.draw/spec/suites/GeometryUtilSpec.js +25 -0
  22. data/lib/leaflet.draw/spec/suites/LatLngUtilSpec.js +9 -0
  23. data/lib/leaflet.draw/src/Control.Draw.js +1 -0
  24. data/lib/leaflet.draw/src/Leaflet.draw.js +89 -1
  25. data/lib/leaflet.draw/src/Toolbar.js +2 -6
  26. data/lib/leaflet.draw/src/Tooltip.js +20 -7
  27. data/lib/leaflet.draw/src/draw/DrawToolbar.js +26 -22
  28. data/lib/leaflet.draw/src/draw/handler/Draw.Circle.js +11 -6
  29. data/lib/leaflet.draw/src/draw/handler/Draw.Feature.js +6 -2
  30. data/lib/leaflet.draw/src/draw/handler/Draw.Marker.js +7 -2
  31. data/lib/leaflet.draw/src/draw/handler/Draw.Polygon.js +29 -7
  32. data/lib/leaflet.draw/src/draw/handler/Draw.Polyline.js +44 -21
  33. data/lib/leaflet.draw/src/draw/handler/Draw.Rectangle.js +3 -3
  34. data/lib/leaflet.draw/src/draw/handler/Draw.SimpleShape.js +14 -1
  35. data/lib/leaflet.draw/src/edit/EditToolbar.js +86 -16
  36. data/lib/leaflet.draw/src/edit/handler/Edit.Poly.js +10 -7
  37. data/lib/leaflet.draw/src/edit/handler/Edit.SimpleShape.js +1 -2
  38. data/lib/leaflet.draw/src/edit/handler/EditToolbar.Delete.js +15 -3
  39. data/lib/leaflet.draw/src/edit/handler/EditToolbar.Edit.js +56 -38
  40. data/lib/leaflet.draw/src/ext/GeometryUtil.js +68 -0
  41. data/lib/leaflet.draw/src/images/spritesheet.svg +41 -0
  42. data/lib/leaflet.label/CHANGELOG.md +32 -0
  43. data/lib/leaflet.label/README.md +21 -4
  44. data/lib/leaflet.label/build/build.js +2 -2
  45. data/lib/leaflet.label/build/deps.js +2 -0
  46. data/lib/leaflet.label/build/hintrc.js +4 -0
  47. data/lib/leaflet.label/dist/leaflet.label-src.js +266 -83
  48. data/lib/leaflet.label/dist/leaflet.label.css +23 -4
  49. data/lib/leaflet.label/dist/leaflet.label.js +1 -1
  50. data/lib/leaflet.label/example/label.html +6 -3
  51. data/lib/leaflet.label/libs/leaflet/images/layers-2x.png +0 -0
  52. data/lib/leaflet.label/libs/leaflet/images/layers.png +0 -0
  53. data/lib/leaflet.label/libs/leaflet/images/marker-icon-2x.png +0 -0
  54. data/lib/leaflet.label/libs/leaflet/leaflet-src.js +1129 -608
  55. data/lib/leaflet.label/libs/leaflet/leaflet.css +85 -66
  56. data/lib/leaflet.label/libs/leaflet/leaflet.js +6 -5
  57. data/lib/leaflet.label/package.json +19 -0
  58. data/lib/leaflet.label/src/BaseMarkerMethods.js +129 -0
  59. data/lib/leaflet.label/src/CircleMarker.Label.js +7 -0
  60. data/lib/leaflet.label/src/Label.js +161 -37
  61. data/lib/leaflet.label/src/Leaflet.label.js +1 -1
  62. data/lib/leaflet.label/src/Map.Label.js +0 -2
  63. data/lib/leaflet.label/src/Marker.Label.js +15 -120
  64. data/lib/leaflet.label/src/Path.Label.js +11 -11
  65. data/lib/leaflet/CHANGELOG.md +299 -31
  66. data/lib/leaflet/CONTRIBUTING.md +3 -3
  67. data/lib/leaflet/FAQ.md +138 -0
  68. data/lib/leaflet/Jakefile.js +24 -4
  69. data/lib/leaflet/PLUGIN-GUIDE.md +127 -0
  70. data/lib/leaflet/README.md +10 -6
  71. data/lib/leaflet/build/build.html +3 -19
  72. data/lib/leaflet/build/build.js +21 -51
  73. data/lib/leaflet/build/deps.js +10 -7
  74. data/lib/leaflet/build/hintrc.js +6 -4
  75. data/lib/leaflet/debug/hacks/jitter.html +0 -1
  76. data/lib/leaflet/debug/map/canvas.html +11 -12
  77. data/lib/leaflet/debug/map/controls.html +3 -4
  78. data/lib/leaflet/debug/map/geolocation.html +0 -1
  79. data/lib/leaflet/debug/map/iframe.html +11 -0
  80. data/lib/leaflet/debug/map/image-overlay.html +0 -1
  81. data/lib/leaflet/debug/map/map-mobile.html +0 -1
  82. data/lib/leaflet/debug/map/map.html +1 -2
  83. data/lib/leaflet/debug/map/max-bounds.html +2 -1
  84. data/lib/leaflet/debug/map/opacity.html +223 -0
  85. data/lib/leaflet/debug/map/scroll.html +6 -1
  86. data/lib/leaflet/debug/map/simple-proj.html +0 -1
  87. data/lib/leaflet/debug/map/wms-marble.html +4 -5
  88. data/lib/leaflet/debug/map/wms.html +0 -1
  89. data/lib/leaflet/debug/map/zoomlevels.html +0 -1
  90. data/lib/leaflet/debug/tests/add_remove_layers.html +5 -6
  91. data/lib/leaflet/debug/tests/bringtoback.html +0 -1
  92. data/lib/leaflet/debug/tests/canvasloop.html +47 -0
  93. data/lib/leaflet/debug/tests/click_on_canvas.html +0 -1
  94. data/lib/leaflet/debug/tests/dragging_and_copyworldjump.html +61 -0
  95. data/lib/leaflet/debug/tests/opacity.html +0 -1
  96. data/lib/leaflet/debug/tests/popupcontextmenuclicks.html +59 -0
  97. data/lib/leaflet/debug/tests/remove_while_dragging.html +4 -5
  98. data/lib/leaflet/debug/tests/removetilewhilepan.html +0 -1
  99. data/lib/leaflet/debug/tests/reuse_popups.html +0 -1
  100. data/lib/leaflet/debug/tests/rtl.html +42 -0
  101. data/lib/leaflet/debug/tests/rtl2.html +27 -0
  102. data/lib/leaflet/debug/tests/set_icon_reuse_dom.html +43 -0
  103. data/lib/leaflet/debug/tests/svg_clicks.html +3 -4
  104. data/lib/leaflet/debug/vector/bounds-extend.html +0 -1
  105. data/lib/leaflet/debug/vector/feature-group-bounds.html +0 -1
  106. data/lib/leaflet/debug/vector/geojson.html +0 -1
  107. data/lib/leaflet/debug/vector/rectangle.html +0 -1
  108. data/lib/leaflet/debug/vector/touchzoomemu.html +2 -3
  109. data/lib/leaflet/debug/vector/vector-bounds.html +0 -1
  110. data/lib/leaflet/debug/vector/vector-canvas.html +0 -1
  111. data/lib/leaflet/debug/vector/vector-mobile.html +0 -1
  112. data/lib/leaflet/debug/vector/vector-simple.html +0 -1
  113. data/lib/leaflet/debug/vector/vector.html +0 -1
  114. data/lib/leaflet/dist/images/layers-2x.png +0 -0
  115. data/lib/leaflet/dist/images/layers.png +0 -0
  116. data/lib/leaflet/dist/leaflet.css +85 -66
  117. data/lib/leaflet/package.json +25 -20
  118. data/lib/leaflet/spec/after.js +1 -1
  119. data/lib/leaflet/spec/index.html +21 -13
  120. data/lib/leaflet/spec/karma.conf.js +51 -50
  121. data/lib/leaflet/spec/spec.hintrc.js +25 -0
  122. data/lib/leaflet/spec/suites/LeafletSpec.js +2 -2
  123. data/lib/leaflet/spec/suites/SpecHelper.js +37 -21
  124. data/lib/leaflet/spec/suites/control/Control.LayersSpec.js +1 -1
  125. data/lib/leaflet/spec/suites/core/ClassSpec.js +12 -12
  126. data/lib/leaflet/spec/suites/core/EventsSpec.js +74 -18
  127. data/lib/leaflet/spec/suites/core/UtilSpec.js +69 -25
  128. data/lib/leaflet/spec/suites/dom/DomEventSpec.js +16 -16
  129. data/lib/leaflet/spec/suites/dom/DomUtilSpec.js +9 -16
  130. data/lib/leaflet/spec/suites/dom/PosAnimationSpec.js +27 -0
  131. data/lib/leaflet/spec/suites/geo/CRSSpec.js +47 -0
  132. data/lib/leaflet/spec/suites/geo/LatLngBoundsSpec.js +22 -14
  133. data/lib/leaflet/spec/suites/geo/LatLngSpec.js +22 -8
  134. data/lib/leaflet/spec/suites/geo/ProjectionSpec.js +21 -20
  135. data/lib/leaflet/spec/suites/geometry/BoundsSpec.js +15 -15
  136. data/lib/leaflet/spec/suites/geometry/PointSpec.js +12 -12
  137. data/lib/leaflet/spec/suites/geometry/TransformationSpec.js +4 -4
  138. data/lib/leaflet/spec/suites/layer/FeatureGroupSpec.js +59 -9
  139. data/lib/leaflet/spec/suites/layer/GeoJSONSpec.js +213 -17
  140. data/lib/leaflet/spec/suites/layer/LayerGroupSpec.js +6 -6
  141. data/lib/leaflet/spec/suites/layer/PopupSpec.js +65 -5
  142. data/lib/leaflet/spec/suites/layer/TileLayerSpec.js +16 -15
  143. data/lib/leaflet/spec/suites/layer/marker/MarkerSpec.js +94 -0
  144. data/lib/leaflet/spec/suites/layer/vector/CircleMarkerSpec.js +7 -7
  145. data/lib/leaflet/spec/suites/layer/vector/PolygonSpec.js +38 -2
  146. data/lib/leaflet/spec/suites/layer/vector/PolylineGeometrySpec.js +4 -4
  147. data/lib/leaflet/spec/suites/layer/vector/PolylineSpec.js +2 -2
  148. data/lib/leaflet/spec/suites/map/MapSpec.js +318 -26
  149. data/lib/leaflet/spec/suites/map/handler/Map.DragSpec.js +38 -0
  150. data/lib/leaflet/src/Leaflet.js +2 -2
  151. data/lib/leaflet/src/control/Control.Attribution.js +6 -0
  152. data/lib/leaflet/src/control/Control.Layers.js +33 -24
  153. data/lib/leaflet/src/control/Control.Zoom.js +12 -4
  154. data/lib/leaflet/src/control/Control.js +10 -0
  155. data/lib/leaflet/src/copyright.js +2 -1
  156. data/lib/leaflet/src/core/Browser.js +11 -10
  157. data/lib/leaflet/src/core/Events.js +15 -11
  158. data/lib/leaflet/src/core/Util.js +19 -14
  159. data/lib/leaflet/src/dom/DomEvent.DoubleTap.js +13 -12
  160. data/lib/leaflet/src/dom/DomEvent.Pointer.js +155 -0
  161. data/lib/leaflet/src/dom/DomEvent.js +57 -19
  162. data/lib/leaflet/src/dom/DomUtil.js +89 -34
  163. data/lib/leaflet/src/dom/Draggable.js +26 -89
  164. data/lib/leaflet/src/dom/PosAnimation.js +13 -2
  165. data/lib/leaflet/src/geo/LatLng.js +16 -5
  166. data/lib/leaflet/src/geo/LatLngBounds.js +5 -2
  167. data/lib/leaflet/src/geo/crs/CRS.EPSG3395.js +2 -2
  168. data/lib/leaflet/src/geo/crs/CRS.js +5 -0
  169. data/lib/leaflet/src/geo/projection/Projection.Mercator.js +3 -3
  170. data/lib/leaflet/src/geometry/LineUtil.js +2 -2
  171. data/lib/leaflet/src/images/layers.svg +8 -0
  172. data/lib/leaflet/src/images/marker.svg +61 -1
  173. data/lib/leaflet/src/layer/FeatureGroup.js +24 -7
  174. data/lib/leaflet/src/layer/GeoJSON.js +97 -56
  175. data/lib/leaflet/src/layer/ImageOverlay.js +9 -0
  176. data/lib/leaflet/src/layer/LayerGroup.js +8 -3
  177. data/lib/leaflet/src/layer/Popup.js +56 -34
  178. data/lib/leaflet/src/layer/marker/DivIcon.js +4 -2
  179. data/lib/leaflet/src/layer/marker/Icon.Default.js +1 -1
  180. data/lib/leaflet/src/layer/marker/Icon.js +15 -18
  181. data/lib/leaflet/src/layer/marker/Marker.Drag.js +7 -5
  182. data/lib/leaflet/src/layer/marker/Marker.Popup.js +22 -5
  183. data/lib/leaflet/src/layer/marker/Marker.js +75 -32
  184. data/lib/leaflet/src/layer/tile/TileLayer.Anim.js +14 -26
  185. data/lib/leaflet/src/layer/tile/TileLayer.Canvas.js +7 -6
  186. data/lib/leaflet/src/layer/tile/TileLayer.WMS.js +14 -10
  187. data/lib/leaflet/src/layer/tile/TileLayer.js +53 -32
  188. data/lib/leaflet/src/layer/vector/CircleMarker.js +11 -0
  189. data/lib/leaflet/src/layer/vector/MultiPoly.js +10 -0
  190. data/lib/leaflet/src/layer/vector/Path.SVG.js +14 -3
  191. data/lib/leaflet/src/layer/vector/Path.VML.js +12 -2
  192. data/lib/leaflet/src/layer/vector/Path.js +7 -3
  193. data/lib/leaflet/src/layer/vector/Polygon.js +14 -3
  194. data/lib/leaflet/src/layer/vector/canvas/CircleMarker.Canvas.js +9 -0
  195. data/lib/leaflet/src/layer/vector/canvas/Path.Canvas.js +1 -0
  196. data/lib/leaflet/src/map/Map.js +192 -125
  197. data/lib/leaflet/src/map/anim/Map.PanAnimation.js +29 -19
  198. data/lib/leaflet/src/map/anim/Map.ZoomAnimation.js +21 -9
  199. data/lib/leaflet/src/map/ext/Map.Geolocation.js +11 -4
  200. data/lib/leaflet/src/map/handler/Map.BoxZoom.js +26 -12
  201. data/lib/leaflet/src/map/handler/Map.DoubleClickZoom.js +10 -3
  202. data/lib/leaflet/src/map/handler/Map.Drag.js +12 -6
  203. data/lib/leaflet/src/map/handler/Map.Keyboard.js +5 -2
  204. data/lib/leaflet/src/map/handler/Map.ScrollWheelZoom.js +7 -1
  205. data/lib/leaflet/src/map/handler/Map.Tap.js +107 -0
  206. data/lib/leaflet/src/map/handler/Map.TouchZoom.js +9 -3
  207. data/vendor/assets/images/layers-2x.png +0 -0
  208. data/vendor/assets/images/layers.png +0 -0
  209. data/vendor/assets/images/spritesheet-2x.png +0 -0
  210. data/vendor/assets/images/spritesheet.png +0 -0
  211. data/vendor/assets/javascripts/leaflet.draw.js +2 -4
  212. data/vendor/assets/javascripts/leaflet.js +3 -1
  213. data/vendor/assets/javascripts/leaflet.label.js +2 -0
  214. data/vendor/assets/stylesheets/leaflet.css.erb +337 -318
  215. data/vendor/assets/stylesheets/leaflet.draw.css.erb +35 -3
  216. data/vendor/assets/stylesheets/leaflet.draw.ie.css +5 -0
  217. data/vendor/assets/stylesheets/leaflet.label.css +23 -4
  218. metadata +40 -14
  219. data/lib/leaflet.draw/examples/libs/leaflet.ie.css +0 -51
  220. data/lib/leaflet.label/libs/leaflet/leaflet.ie.css +0 -51
  221. data/lib/leaflet/dist/leaflet-src.js +0 -8579
  222. data/lib/leaflet/dist/leaflet.ie.css +0 -51
  223. data/lib/leaflet/dist/leaflet.js +0 -8
  224. data/lib/leaflet/spec/happen.js +0 -93
  225. data/lib/leaflet/src/dom/DomEvent.MsTouch.js +0 -146
  226. data/vendor/assets/stylesheets/leaflet.ie.css +0 -51
@@ -1,6 +1,6 @@
1
- describe('LatLng', function() {
2
- describe('constructor', function() {
3
- it("sets lat and lng", function() {
1
+ describe('LatLng', function () {
2
+ describe('constructor', function () {
3
+ it("sets lat and lng", function () {
4
4
  var a = new L.LatLng(25, 74);
5
5
  expect(a.lat).to.eql(25);
6
6
  expect(a.lng).to.eql(74);
@@ -15,16 +15,30 @@ describe('LatLng', function() {
15
15
  var a = new L.LatLng(NaN, NaN);
16
16
  }).to.throwError();
17
17
  });
18
+
19
+ it('does not set altitude if undefined', function () {
20
+ var a = new L.LatLng(25, 74);
21
+ expect(typeof a.alt).to.eql('undefined');
22
+ });
23
+
24
+ it('sets altitude', function () {
25
+ var a = new L.LatLng(25, 74, 50);
26
+ expect(a.alt).to.eql(50);
27
+
28
+ var b = new L.LatLng(-25, -74, -50);
29
+ expect(b.alt).to.eql(-50);
30
+ });
31
+
18
32
  });
19
33
 
20
- describe('#equals', function() {
21
- it("returns true if compared objects are equal within a certain margin", function() {
34
+ describe('#equals', function () {
35
+ it("returns true if compared objects are equal within a certain margin", function () {
22
36
  var a = new L.LatLng(10, 20);
23
37
  var b = new L.LatLng(10 + 1.0E-10, 20 - 1.0E-10);
24
38
  expect(a.equals(b)).to.eql(true);
25
39
  });
26
40
 
27
- it("returns false if compared objects are not equal within a certain margin", function() {
41
+ it("returns false if compared objects are not equal within a certain margin", function () {
28
42
  var a = new L.LatLng(10, 20);
29
43
  var b = new L.LatLng(10, 23.3);
30
44
  expect(a.equals(b)).to.eql(false);
@@ -37,7 +51,7 @@ describe('LatLng', function() {
37
51
  });
38
52
 
39
53
  describe('#wrap', function () {
40
- it("wraps longitude to lie between -180 and 180 by default", function() {
54
+ it("wraps longitude to lie between -180 and 180 by default", function () {
41
55
  var a = new L.LatLng(0, 190).wrap().lng;
42
56
  expect(a).to.eql(-170);
43
57
 
@@ -63,7 +77,7 @@ describe('LatLng', function() {
63
77
  expect(h).to.eql(180);
64
78
  });
65
79
 
66
- it("wraps longitude within the given range", function() {
80
+ it("wraps longitude within the given range", function () {
67
81
  var a = new L.LatLng(0, 190).wrap(-100, 100).lng;
68
82
  expect(a).to.eql(-10);
69
83
  });
@@ -1,47 +1,48 @@
1
- describe("Projection.Mercator", function() {
1
+ describe("Projection.Mercator", function () {
2
2
  var p = L.Projection.Mercator;
3
3
 
4
- expect.Assertion.prototype.near = function(expected, delta) {
5
- delta = delta || 1;
6
- expect(this.obj.x).to
7
- .be.within(expected.x - delta, expected.x + delta);
8
- expect(this.obj.y).to
9
- .be.within(expected.y - delta, expected.y + delta);
10
- };
11
-
12
- describe("#project", function() {
13
- it("projects a center point", function() {
4
+ describe("#project", function () {
5
+ it("projects a center point", function () {
14
6
  //edge cases
15
7
  expect(p.project(new L.LatLng(0, 0))).near(new L.Point(0, 0));
16
8
  });
17
9
 
18
- it("projects the northeast corner of the world", function() {
19
- expect(p.project(new L.LatLng(90, 180))).near(new L.Point(20037508.342789244, 19970326.50745906));
10
+ it("projects the northeast corner of the world", function () {
11
+ expect(p.project(new L.LatLng(90, 180))).near(new L.Point(20037508, 20037508));
20
12
  });
21
13
 
22
- it("projects the southwest corner of the world", function() {
23
- expect(p.project(new L.LatLng(-90, -180))).near(new L.Point(-20037508, -19970326));
14
+ it("projects the southwest corner of the world", function () {
15
+ expect(p.project(new L.LatLng(-90, -180))).near(new L.Point(-20037508, -20037508));
24
16
  });
25
17
 
26
- it("projects 50, 30", function() {
27
- expect(p.project(new L.LatLng(50, 30))).near(new L.Point(3339584, 6392021));
18
+ it("projects other points", function () {
19
+ expect(p.project(new L.LatLng(50, 30))).near(new L.Point(3339584, 6413524));
20
+
21
+ // from https://github.com/Leaflet/Leaflet/issues/1578
22
+ expect(p.project(new L.LatLng(51.9371170300465, 80.11230468750001)))
23
+ .near(new L.Point(8918060.964088084, 6755099.410887127));
28
24
  });
29
25
  });
30
26
 
31
- describe("#unproject", function() {
27
+ describe("#unproject", function () {
32
28
  function pr(point) {
33
29
  return p.project(p.unproject(point));
34
30
  }
35
31
 
36
- it("unprojects a center point", function() {
32
+ it("unprojects a center point", function () {
37
33
  expect(pr(new L.Point(0, 0))).near(new L.Point(0, 0));
38
34
  });
39
35
 
40
- it("pi points", function() {
36
+ it("unprojects pi points", function () {
41
37
  expect(pr(new L.Point(-Math.PI, Math.PI))).near(new L.Point(-Math.PI, Math.PI));
42
38
  expect(pr(new L.Point(-Math.PI, -Math.PI))).near(new L.Point(-Math.PI, -Math.PI));
43
39
 
44
40
  expect(pr(new L.Point(0.523598775598, 1.010683188683))).near(new L.Point(0.523598775598, 1.010683188683));
45
41
  });
42
+
43
+ it('unprojects other points', function () {
44
+ // from https://github.com/Leaflet/Leaflet/issues/1578
45
+ expect(pr(new L.Point(8918060.964088084, 6755099.410887127)));
46
+ });
46
47
  });
47
48
  });
@@ -1,7 +1,7 @@
1
- describe('Bounds', function() {
1
+ describe('Bounds', function () {
2
2
  var a, b, c;
3
3
 
4
- beforeEach(function() {
4
+ beforeEach(function () {
5
5
  a = new L.Bounds(
6
6
  new L.Point(14, 12),
7
7
  new L.Point(30, 40));
@@ -13,19 +13,19 @@ describe('Bounds', function() {
13
13
  c = new L.Bounds();
14
14
  });
15
15
 
16
- describe('constructor', function() {
17
- it('creates bounds with proper min & max on (Point, Point)', function() {
16
+ describe('constructor', function () {
17
+ it('creates bounds with proper min & max on (Point, Point)', function () {
18
18
  expect(a.min).to.eql(new L.Point(14, 12));
19
19
  expect(a.max).to.eql(new L.Point(30, 40));
20
20
  });
21
- it('creates bounds with proper min & max on (Point[])', function() {
21
+ it('creates bounds with proper min & max on (Point[])', function () {
22
22
  expect(b.min).to.eql(new L.Point(14, 12));
23
23
  expect(b.max).to.eql(new L.Point(30, 40));
24
24
  });
25
25
  });
26
26
 
27
- describe('#extend', function() {
28
- it('extends the bounds to contain the given point', function() {
27
+ describe('#extend', function () {
28
+ it('extends the bounds to contain the given point', function () {
29
29
  a.extend(new L.Point(50, 20));
30
30
  expect(a.min).to.eql(new L.Point(14, 12));
31
31
  expect(a.max).to.eql(new L.Point(50, 40));
@@ -36,14 +36,14 @@ describe('Bounds', function() {
36
36
  });
37
37
  });
38
38
 
39
- describe('#getCenter', function() {
40
- it('returns the center point', function() {
39
+ describe('#getCenter', function () {
40
+ it('returns the center point', function () {
41
41
  expect(a.getCenter()).to.eql(new L.Point(22, 26));
42
42
  });
43
43
  });
44
44
 
45
- describe('#contains', function() {
46
- it('contains other bounds or point', function() {
45
+ describe('#contains', function () {
46
+ it('contains other bounds or point', function () {
47
47
  a.extend(new L.Point(50, 10));
48
48
  expect(a.contains(b)).to.be.ok();
49
49
  expect(b.contains(a)).to.not.be.ok();
@@ -52,14 +52,14 @@ describe('Bounds', function() {
52
52
  });
53
53
  });
54
54
 
55
- describe('#isValid', function() {
56
- it('returns true if properly set up', function() {
55
+ describe('#isValid', function () {
56
+ it('returns true if properly set up', function () {
57
57
  expect(a.isValid()).to.be.ok();
58
58
  });
59
- it('returns false if is invalid', function() {
59
+ it('returns false if is invalid', function () {
60
60
  expect(c.isValid()).to.not.be.ok();
61
61
  });
62
- it('returns true if extended', function() {
62
+ it('returns true if extended', function () {
63
63
  c.extend([0, 0]);
64
64
  expect(c.isValid()).to.be.ok();
65
65
  });
@@ -1,42 +1,42 @@
1
- describe("Point", function() {
1
+ describe("Point", function () {
2
2
 
3
- describe('constructor', function() {
3
+ describe('constructor', function () {
4
4
 
5
- it("creates a point with the given x and y", function() {
5
+ it("creates a point with the given x and y", function () {
6
6
  var p = new L.Point(1.5, 2.5);
7
7
  expect(p.x).to.eql(1.5);
8
8
  expect(p.y).to.eql(2.5);
9
9
  });
10
10
 
11
- it("rounds the given x and y if the third argument is true", function() {
11
+ it("rounds the given x and y if the third argument is true", function () {
12
12
  var p = new L.Point(1.3, 2.7, true);
13
13
  expect(p.x).to.eql(1);
14
14
  expect(p.y).to.eql(3);
15
15
  });
16
16
  });
17
17
 
18
- describe('#subtract', function() {
19
- it('subtracts the given point from this one', function() {
18
+ describe('#subtract', function () {
19
+ it('subtracts the given point from this one', function () {
20
20
  var a = new L.Point(50, 30),
21
21
  b = new L.Point(20, 10);
22
22
  expect(a.subtract(b)).to.eql(new L.Point(30, 20));
23
23
  });
24
24
  });
25
25
 
26
- describe('#add', function() {
27
- it('adds given point to this one', function() {
26
+ describe('#add', function () {
27
+ it('adds given point to this one', function () {
28
28
  expect(new L.Point(50, 30).add(new L.Point(20, 10))).to.eql(new L.Point(70, 40));
29
29
  });
30
30
  });
31
31
 
32
- describe('#divideBy', function() {
33
- it('divides this point by the given amount', function() {
32
+ describe('#divideBy', function () {
33
+ it('divides this point by the given amount', function () {
34
34
  expect(new L.Point(50, 30).divideBy(5)).to.eql(new L.Point(10, 6));
35
35
  });
36
36
  });
37
37
 
38
- describe('#multiplyBy', function() {
39
- it('multiplies this point by the given amount', function() {
38
+ describe('#multiplyBy', function () {
39
+ it('multiplies this point by the given amount', function () {
40
40
  expect(new L.Point(50, 30).multiplyBy(2)).to.eql(new L.Point(100, 60));
41
41
  });
42
42
  });
@@ -1,13 +1,13 @@
1
- describe("Transformation", function() {
1
+ describe("Transformation", function () {
2
2
  var t, p;
3
3
 
4
- beforeEach(function() {
4
+ beforeEach(function () {
5
5
  t = new L.Transformation(1, 2, 3, 4);
6
6
  p = new L.Point(10, 20);
7
7
  });
8
8
 
9
9
  describe('#transform', function () {
10
- it("performs a transformation", function() {
10
+ it("performs a transformation", function () {
11
11
  var p2 = t.transform(p, 2);
12
12
  expect(p2).to.eql(new L.Point(24, 128));
13
13
  });
@@ -18,7 +18,7 @@ describe("Transformation", function() {
18
18
  });
19
19
 
20
20
  describe('#untransform', function () {
21
- it("performs a reverse transformation", function() {
21
+ it("performs a reverse transformation", function () {
22
22
  var p2 = t.transform(p, 2);
23
23
  var p3 = t.untransform(p2, 2);
24
24
  expect(p3).to.eql(p);
@@ -1,9 +1,12 @@
1
- describe('CircleMarker', function () {
1
+ describe('FeatureGroup', function () {
2
+ var map;
3
+ beforeEach(function () {
4
+ map = L.map(document.createElement('div'));
5
+ map.setView([0, 0], 1);
6
+ });
2
7
  describe("#_propagateEvent", function () {
3
- var map, marker;
8
+ var marker;
4
9
  beforeEach(function () {
5
- map = L.map(document.createElement('div'));
6
- map.setView([0, 0], 1);
7
10
  marker = L.marker([0, 0]);
8
11
  });
9
12
  describe("when a Marker is added to multiple FeatureGroups ", function () {
@@ -14,23 +17,70 @@
14
17
  fg1.addLayer(marker);
15
18
  fg2.addLayer(marker);
16
19
 
17
- var wasClicked = 0;
18
- fg2.on('click', function(e) {
20
+ var wasClicked1,
21
+ wasClicked2;
22
+
23
+ fg2.on('click', function (e) {
19
24
  expect(e.layer).to.be(marker);
20
25
  expect(e.target).to.be(fg2);
21
- wasClicked |= 1;
26
+ wasClicked2 = true;
22
27
  });
23
28
 
24
29
  fg1.on('click', function (e) {
25
30
  expect(e.layer).to.be(marker);
26
31
  expect(e.target).to.be(fg1);
27
- wasClicked |= 2;
32
+ wasClicked1 = true;
28
33
  });
29
34
 
30
35
  marker.fire('click', { type: 'click' });
31
36
 
32
- expect(wasClicked).to.be(3);
37
+ expect(wasClicked1).to.be(true);
38
+ expect(wasClicked2).to.be(true);
33
39
  });
34
40
  });
35
41
  });
42
+ describe('addLayer', function () {
43
+ it('adds the layer', function () {
44
+ var fg = L.featureGroup(),
45
+ marker = L.marker([0, 0]);
46
+
47
+ expect(fg.hasLayer(marker)).to.be(false);
48
+
49
+ fg.addLayer(marker);
50
+
51
+ expect(fg.hasLayer(marker)).to.be(true);
52
+ });
53
+ it('supports non-evented layers', function () {
54
+ var fg = L.featureGroup(),
55
+ g = L.layerGroup();
56
+
57
+ expect(fg.hasLayer(g)).to.be(false);
58
+
59
+ fg.addLayer(g);
60
+
61
+ expect(fg.hasLayer(g)).to.be(true);
62
+ });
63
+ });
64
+ describe('removeLayer', function () {
65
+ it('removes the layer passed to it', function () {
66
+ var fg = L.featureGroup(),
67
+ marker = L.marker([0, 0]);
68
+
69
+ fg.addLayer(marker);
70
+ expect(fg.hasLayer(marker)).to.be(true);
71
+
72
+ fg.removeLayer(marker);
73
+ expect(fg.hasLayer(marker)).to.be(false);
74
+ });
75
+ it('removes the layer passed to it by id', function () {
76
+ var fg = L.featureGroup(),
77
+ marker = L.marker([0, 0]);
78
+
79
+ fg.addLayer(marker);
80
+ expect(fg.hasLayer(marker)).to.be(true);
81
+
82
+ fg.removeLayer(L.stamp(marker));
83
+ expect(fg.hasLayer(marker)).to.be(false);
84
+ });
85
+ });
36
86
  });
@@ -1,27 +1,104 @@
1
+ describe("L.GeoJSON", function () {
2
+ describe("addData", function () {
3
+ var geoJSON = {
4
+ type: 'Feature',
5
+ properties: {},
6
+ geometry: {
7
+ type: 'Point',
8
+ coordinates: [20, 10, 5]
9
+ }
10
+ };
11
+
12
+ it("sets feature property on member layers", function () {
13
+ var layer = new L.GeoJSON();
14
+ layer.addData(geoJSON);
15
+ expect(layer.getLayers()[0].feature).to.eql(geoJSON);
16
+ });
17
+
18
+ it("normalizes a geometry to a Feature", function () {
19
+ var layer = new L.GeoJSON();
20
+ layer.addData(geoJSON.geometry);
21
+ expect(layer.getLayers()[0].feature).to.eql(geoJSON);
22
+ });
23
+ });
24
+ });
25
+
1
26
  describe("L.Marker#toGeoJSON", function () {
2
- it("returns a Point object", function () {
27
+ it("returns a 2D Point object", function () {
3
28
  var marker = new L.Marker([10, 20]);
4
- expect(marker.toGeoJSON()).to.eql({
29
+ expect(marker.toGeoJSON().geometry).to.eql({
30
+ type: 'Point',
31
+ coordinates: [20, 10]
32
+ });
33
+ });
34
+
35
+ it("returns a 3D Point object", function () {
36
+ var marker = new L.Marker([10, 20, 30]);
37
+ expect(marker.toGeoJSON().geometry).to.eql({
38
+ type: 'Point',
39
+ coordinates: [20, 10, 30]
40
+ });
41
+ });
42
+ });
43
+
44
+ describe("L.Circle#toGeoJSON", function () {
45
+ it("returns a 2D Point object", function () {
46
+ var circle = new L.Circle([10, 20], 100);
47
+ expect(circle.toGeoJSON().geometry).to.eql({
48
+ type: 'Point',
49
+ coordinates: [20, 10]
50
+ });
51
+ });
52
+
53
+ it("returns a 3D Point object", function () {
54
+ var circle = new L.Circle([10, 20, 30], 100);
55
+ expect(circle.toGeoJSON().geometry).to.eql({
56
+ type: 'Point',
57
+ coordinates: [20, 10, 30]
58
+ });
59
+ });
60
+ });
61
+
62
+ describe("L.CircleMarker#toGeoJSON", function () {
63
+ it("returns a 2D Point object", function () {
64
+ var marker = new L.CircleMarker([10, 20]);
65
+ expect(marker.toGeoJSON().geometry).to.eql({
5
66
  type: 'Point',
6
67
  coordinates: [20, 10]
7
68
  });
8
69
  });
70
+
71
+ it("returns a 3D Point object", function () {
72
+ var marker = new L.CircleMarker([10, 20, 30]);
73
+ expect(marker.toGeoJSON().geometry).to.eql({
74
+ type: 'Point',
75
+ coordinates: [20, 10, 30]
76
+ });
77
+ });
9
78
  });
10
79
 
11
80
  describe("L.Polyline#toGeoJSON", function () {
12
- it("returns a LineString object", function () {
81
+ it("returns a 2D LineString object", function () {
13
82
  var polyline = new L.Polyline([[10, 20], [2, 5]]);
14
- expect(polyline.toGeoJSON()).to.eql({
83
+ expect(polyline.toGeoJSON().geometry).to.eql({
15
84
  type: 'LineString',
16
85
  coordinates: [[20, 10], [5, 2]]
17
86
  });
18
87
  });
88
+
89
+ it("returns a 3D LineString object", function () {
90
+ var polyline = new L.Polyline([[10, 20, 30], [2, 5, 10]]);
91
+ expect(polyline.toGeoJSON().geometry).to.eql({
92
+ type: 'LineString',
93
+ coordinates: [[20, 10, 30], [5, 2, 10]]
94
+ });
95
+ });
19
96
  });
20
97
 
21
98
  describe("L.MultiPolyline#toGeoJSON", function () {
22
- it("returns a MultiLineString object", function () {
99
+ it("returns a 2D MultiLineString object", function () {
23
100
  var multiPolyline = new L.MultiPolyline([[[10, 20], [2, 5]], [[1, 2], [3, 4]]]);
24
- expect(multiPolyline.toGeoJSON()).to.eql({
101
+ expect(multiPolyline.toGeoJSON().geometry).to.eql({
25
102
  type: 'MultiLineString',
26
103
  coordinates: [
27
104
  [[20, 10], [5, 2]],
@@ -29,20 +106,39 @@ describe("L.MultiPolyline#toGeoJSON", function () {
29
106
  ]
30
107
  });
31
108
  });
109
+
110
+ it("returns a 3D MultiLineString object", function () {
111
+ var multiPolyline = new L.MultiPolyline([[[10, 20, 30], [2, 5, 10]], [[1, 2, 3], [4, 5, 6]]]);
112
+ expect(multiPolyline.toGeoJSON().geometry).to.eql({
113
+ type: 'MultiLineString',
114
+ coordinates: [
115
+ [[20, 10, 30], [5, 2, 10]],
116
+ [[2, 1, 3], [5, 4, 6]]
117
+ ]
118
+ });
119
+ });
32
120
  });
33
121
 
34
122
  describe("L.Polygon#toGeoJSON", function () {
35
- it("returns a Polygon object (no holes)", function () {
123
+ it("returns a 2D Polygon object (no holes)", function () {
36
124
  var polygon = new L.Polygon([[1, 2], [3, 4], [5, 6]]);
37
- expect(polygon.toGeoJSON()).to.eql({
125
+ expect(polygon.toGeoJSON().geometry).to.eql({
38
126
  type: 'Polygon',
39
127
  coordinates: [[[2, 1], [4, 3], [6, 5], [2, 1]]]
40
128
  });
41
129
  });
42
130
 
43
- it("returns a Polygon object (with holes)", function () {
131
+ it("returns a 3D Polygon object (no holes)", function () {
132
+ var polygon = new L.Polygon([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
133
+ expect(polygon.toGeoJSON().geometry).to.eql({
134
+ type: 'Polygon',
135
+ coordinates: [[[2, 1, 3], [5, 4, 6], [8, 7, 9], [2, 1, 3]]]
136
+ });
137
+ });
138
+
139
+ it("returns a 2D Polygon object (with holes)", function () {
44
140
  var polygon = new L.Polygon([[[1, 2], [3, 4], [5, 6]], [[7, 8], [9, 10], [11, 12]]]);
45
- expect(polygon.toGeoJSON()).to.eql({
141
+ expect(polygon.toGeoJSON().geometry).to.eql({
46
142
  type: 'Polygon',
47
143
  coordinates: [
48
144
  [[2, 1], [4, 3], [6, 5], [2, 1]],
@@ -50,37 +146,137 @@ describe("L.Polygon#toGeoJSON", function () {
50
146
  ]
51
147
  });
52
148
  });
149
+
150
+ it("returns a 3D Polygon object (with holes)", function () {
151
+ var polygon = new L.Polygon([[[1, 2, 3], [4, 5, 6], [7, 8, 9]], [[10, 11, 12], [13, 14, 15], [16, 17, 18]]]);
152
+ expect(polygon.toGeoJSON().geometry).to.eql({
153
+ type: 'Polygon',
154
+ coordinates: [
155
+ [[2, 1, 3], [5, 4, 6], [8, 7, 9], [2, 1, 3]],
156
+ [[11, 10, 12], [14, 13, 15], [17, 16, 18], [11, 10, 12]]
157
+ ]
158
+ });
159
+ });
53
160
  });
54
161
 
55
162
  describe("L.MultiPolygon#toGeoJSON", function () {
56
- it("returns a MultiPolygon object", function () {
163
+ it("returns a 2D MultiPolygon object", function () {
57
164
  var multiPolygon = new L.MultiPolygon([[[1, 2], [3, 4], [5, 6]]]);
58
- expect(multiPolygon.toGeoJSON()).to.eql({
165
+ expect(multiPolygon.toGeoJSON().geometry).to.eql({
59
166
  type: 'MultiPolygon',
60
167
  coordinates: [
61
168
  [[[2, 1], [4, 3], [6, 5], [2, 1]]]
62
169
  ]
63
170
  });
64
171
  });
172
+
173
+ it("returns a 3D MultiPolygon object", function () {
174
+ var multiPolygon = new L.MultiPolygon([[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]);
175
+ expect(multiPolygon.toGeoJSON().geometry).to.eql({
176
+ type: 'MultiPolygon',
177
+ coordinates: [
178
+ [[[2, 1, 3], [5, 4, 6], [8, 7, 9], [2, 1, 3]]]
179
+ ]
180
+ });
181
+ });
65
182
  });
66
183
 
67
184
  describe("L.LayerGroup#toGeoJSON", function () {
68
- it("returns a GeometryCollection object", function () {
185
+ it("returns a 2D FeatureCollection object", function () {
69
186
  var marker = new L.Marker([10, 20]),
70
187
  polyline = new L.Polyline([[10, 20], [2, 5]]),
71
188
  layerGroup = new L.LayerGroup([marker, polyline]);
72
189
  expect(layerGroup.toGeoJSON()).to.eql({
73
- type: 'GeometryCollection',
74
- geometries: [marker.toGeoJSON(), polyline.toGeoJSON()]
190
+ type: 'FeatureCollection',
191
+ features: [marker.toGeoJSON(), polyline.toGeoJSON()]
75
192
  });
76
193
  });
77
194
 
195
+ it("returns a 3D FeatureCollection object", function () {
196
+ var marker = new L.Marker([10, 20, 30]),
197
+ polyline = new L.Polyline([[10, 20, 30], [2, 5, 10]]),
198
+ layerGroup = new L.LayerGroup([marker, polyline]);
199
+ expect(layerGroup.toGeoJSON()).to.eql({
200
+ type: 'FeatureCollection',
201
+ features: [marker.toGeoJSON(), polyline.toGeoJSON()]
202
+ });
203
+ });
204
+
205
+ it("ensures that every member is a Feature", function () {
206
+ var tileLayer = new L.TileLayer(),
207
+ layerGroup = new L.LayerGroup([tileLayer]);
208
+
209
+ tileLayer.toGeoJSON = function () {
210
+ return {
211
+ type: 'Point',
212
+ coordinates: [20, 10]
213
+ };
214
+ };
215
+
216
+ expect(layerGroup.toGeoJSON()).to.eql({
217
+ type: 'FeatureCollection',
218
+ features: [{
219
+ type: 'Feature',
220
+ properties: {},
221
+ geometry: {
222
+ type: 'Point',
223
+ coordinates: [20, 10]
224
+ }
225
+ }]
226
+ });
227
+ });
228
+
229
+ it('roundtrips GeometryCollection features', function () {
230
+ var json = {
231
+ "type": "FeatureCollection",
232
+ "features": [{
233
+ "type": "Feature",
234
+ "geometry": {
235
+ "type": "GeometryCollection",
236
+ "geometries": [{
237
+ "type": "LineString",
238
+ "coordinates": [[-122.4425587930444, 37.80666418607323], [-122.4428379594768, 37.80663578323093]]
239
+ }, {
240
+ "type": "LineString",
241
+ "coordinates": [
242
+ [-122.4425509770566, 37.80662588061205],
243
+ [-122.4428340530617, 37.8065999493009]
244
+ ]
245
+ }]
246
+ },
247
+ "properties": {
248
+ "name": "SF Marina Harbor Master"
249
+ }
250
+ }]
251
+ };
252
+
253
+ expect(L.geoJson(json).toGeoJSON()).to.eql(json);
254
+ });
255
+
256
+ it('roundtrips MiltiPoint features', function () {
257
+ var json = {
258
+ "type": "FeatureCollection",
259
+ "features": [{
260
+ "type": "Feature",
261
+ "geometry": {
262
+ "type": "MultiPoint",
263
+ "coordinates": [[-122.4425587930444, 37.80666418607323], [-122.4428379594768, 37.80663578323093]]
264
+ },
265
+ "properties": {
266
+ "name": "Test MultiPoints"
267
+ }
268
+ }]
269
+ };
270
+
271
+ expect(L.geoJson(json).toGeoJSON()).to.eql(json);
272
+ });
273
+
78
274
  it("omits layers which do not implement toGeoJSON", function () {
79
275
  var tileLayer = new L.TileLayer(),
80
276
  layerGroup = new L.LayerGroup([tileLayer]);
81
277
  expect(layerGroup.toGeoJSON()).to.eql({
82
- type: 'GeometryCollection',
83
- geometries: []
278
+ type: 'FeatureCollection',
279
+ features: []
84
280
  });
85
281
  });
86
282
  });