leaflet-js 0.6.beta4 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -0,0 +1,38 @@
1
+ describe("Map.Drag", function () {
2
+ describe("#addHook", function () {
3
+ it("calls the map with dragging enabled", function () {
4
+ var container = document.createElement('div'),
5
+ map = new L.Map(container, {
6
+ dragging: true
7
+ });
8
+
9
+ expect(map.dragging.enabled()).to.be(true);
10
+ map.setView([0, 0], 0);
11
+ expect(map.dragging.enabled()).to.be(true);
12
+ });
13
+ it("calls the map with dragging and worldCopyJump enabled", function () {
14
+ var container = document.createElement('div'),
15
+ map = new L.Map(container, {
16
+ dragging: true,
17
+ worldCopyJump: true
18
+ });
19
+
20
+ expect(map.dragging.enabled()).to.be(true);
21
+ map.setView([0, 0], 0);
22
+ expect(map.dragging.enabled()).to.be(true);
23
+ });
24
+ it("calls the map with dragging disabled and worldCopyJump enabled; " +
25
+ "enables dragging after setting center and zoom", function () {
26
+ var container = document.createElement('div'),
27
+ map = new L.Map(container, {
28
+ dragging: false,
29
+ worldCopyJump: true
30
+ });
31
+
32
+ expect(map.dragging.enabled()).to.be(false);
33
+ map.setView([0, 0], 0);
34
+ map.dragging.enable();
35
+ expect(map.dragging.enabled()).to.be(true);
36
+ });
37
+ });
38
+ });
@@ -2,7 +2,7 @@
2
2
  var oldL = window.L,
3
3
  L = {};
4
4
 
5
- L.version = '0.6-dev';
5
+ L.version = '0.7';
6
6
 
7
7
  // define Leaflet for Node module pattern loaders, including Browserify
8
8
  if (typeof module === 'object' && typeof module.exports === 'object') {
@@ -10,7 +10,7 @@ if (typeof module === 'object' && typeof module.exports === 'object') {
10
10
 
11
11
  // define Leaflet as an AMD module
12
12
  } else if (typeof define === 'function' && define.amd) {
13
- define('leaflet', [], function () { return L; });
13
+ define(L);
14
14
  }
15
15
 
16
16
  // define Leaflet as a global L variable, saving the original L to restore later if needed
@@ -18,6 +18,12 @@ L.Control.Attribution = L.Control.extend({
18
18
  this._container = L.DomUtil.create('div', 'leaflet-control-attribution');
19
19
  L.DomEvent.disableClickPropagation(this._container);
20
20
 
21
+ for (var i in map._layers) {
22
+ if (map._layers[i].getAttribution) {
23
+ this.addAttribution(map._layers[i].getAttribution());
24
+ }
25
+ }
26
+
21
27
  map
22
28
  .on('layeradd', this._onLayerAdd, this)
23
29
  .on('layerremove', this._onLayerRemove, this);
@@ -65,9 +65,13 @@ L.Control.Layers = L.Control.extend({
65
65
  var className = 'leaflet-control-layers',
66
66
  container = this._container = L.DomUtil.create('div', className);
67
67
 
68
+ //Makes this work on IE10 Touch devices by stopping it from firing a mouseout event when the touch is released
69
+ container.setAttribute('aria-haspopup', true);
70
+
68
71
  if (!L.Browser.touch) {
69
- L.DomEvent.disableClickPropagation(container);
70
- L.DomEvent.on(container, 'mousewheel', L.DomEvent.stopPropagation);
72
+ L.DomEvent
73
+ .disableClickPropagation(container)
74
+ .disableScrollPropagation(container);
71
75
  } else {
72
76
  L.DomEvent.on(container, 'click', L.DomEvent.stopPropagation);
73
77
  }
@@ -75,25 +79,29 @@ L.Control.Layers = L.Control.extend({
75
79
  var form = this._form = L.DomUtil.create('form', className + '-list');
76
80
 
77
81
  if (this.options.collapsed) {
78
- L.DomEvent
79
- .on(container, 'mouseover', this._expand, this)
80
- .on(container, 'mouseout', this._collapse, this);
81
-
82
+ if (!L.Browser.android) {
83
+ L.DomEvent
84
+ .on(container, 'mouseover', this._expand, this)
85
+ .on(container, 'mouseout', this._collapse, this);
86
+ }
82
87
  var link = this._layersLink = L.DomUtil.create('a', className + '-toggle', container);
83
88
  link.href = '#';
84
89
  link.title = 'Layers';
85
90
 
86
91
  if (L.Browser.touch) {
87
92
  L.DomEvent
88
- .on(link, 'click', L.DomEvent.stopPropagation)
89
- .on(link, 'click', L.DomEvent.preventDefault)
93
+ .on(link, 'click', L.DomEvent.stop)
90
94
  .on(link, 'click', this._expand, this);
91
95
  }
92
96
  else {
93
97
  L.DomEvent.on(link, 'focus', this._expand, this);
94
98
  }
99
+ //Work around for Firefox android issue https://github.com/Leaflet/Leaflet/issues/2033
100
+ L.DomEvent.on(form, 'click', function () {
101
+ setTimeout(L.bind(this._onInputClick, this), 0);
102
+ }, this);
95
103
 
96
- this._map.on('movestart', this._collapse, this);
104
+ this._map.on('click', this._collapse, this);
97
105
  // TODO keyboard accessibility
98
106
  } else {
99
107
  this._expand();
@@ -144,11 +152,21 @@ L.Control.Layers = L.Control.extend({
144
152
  },
145
153
 
146
154
  _onLayerChange: function (e) {
147
- var id = L.stamp(e.layer);
155
+ var obj = this._layers[L.stamp(e.layer)];
156
+
157
+ if (!obj) { return; }
148
158
 
149
- if (this._layers[id] && !this._handlingClick) {
159
+ if (!this._handlingClick) {
150
160
  this._update();
151
161
  }
162
+
163
+ var type = obj.overlay ?
164
+ (e.type === 'layeradd' ? 'overlayadd' : 'overlayremove') :
165
+ (e.type === 'layeradd' ? 'baselayerchange' : null);
166
+
167
+ if (type) {
168
+ this._map.fire(type, obj);
169
+ }
152
170
  },
153
171
 
154
172
  // IE7 bugs out if you create a radio dynamically, so you have to do it this hacky way (see http://bit.ly/PqYLBe)
@@ -199,8 +217,7 @@ L.Control.Layers = L.Control.extend({
199
217
  _onInputClick: function () {
200
218
  var i, input, obj,
201
219
  inputs = this._form.getElementsByTagName('input'),
202
- inputsLen = inputs.length,
203
- baseLayer;
220
+ inputsLen = inputs.length;
204
221
 
205
222
  this._handlingClick = true;
206
223
 
@@ -210,23 +227,15 @@ L.Control.Layers = L.Control.extend({
210
227
 
211
228
  if (input.checked && !this._map.hasLayer(obj.layer)) {
212
229
  this._map.addLayer(obj.layer);
213
- if (!obj.overlay) {
214
- baseLayer = obj.layer;
215
- } else {
216
- this._map.fire('overlayadd', {layer: obj});
217
- }
230
+
218
231
  } else if (!input.checked && this._map.hasLayer(obj.layer)) {
219
232
  this._map.removeLayer(obj.layer);
220
- this._map.fire('overlayremove', {layer: obj});
221
233
  }
222
234
  }
223
235
 
224
- if (baseLayer) {
225
- this._map.setZoom(this._map.getZoom());
226
- this._map.fire('baselayerchange', {layer: baseLayer});
227
- }
228
-
229
236
  this._handlingClick = false;
237
+
238
+ this._refocusOnMap();
230
239
  },
231
240
 
232
241
  _expand: function () {
@@ -4,7 +4,11 @@
4
4
 
5
5
  L.Control.Zoom = L.Control.extend({
6
6
  options: {
7
- position: 'topleft'
7
+ position: 'topleft',
8
+ zoomInText: '+',
9
+ zoomInTitle: 'Zoom in',
10
+ zoomOutText: '-',
11
+ zoomOutTitle: 'Zoom out'
8
12
  },
9
13
 
10
14
  onAdd: function (map) {
@@ -14,10 +18,13 @@ L.Control.Zoom = L.Control.extend({
14
18
  this._map = map;
15
19
 
16
20
  this._zoomInButton = this._createButton(
17
- '+', 'Zoom in', zoomName + '-in', container, this._zoomIn, this);
21
+ this.options.zoomInText, this.options.zoomInTitle,
22
+ zoomName + '-in', container, this._zoomIn, this);
18
23
  this._zoomOutButton = this._createButton(
19
- '-', 'Zoom out', zoomName + '-out', container, this._zoomOut, this);
24
+ this.options.zoomOutText, this.options.zoomOutTitle,
25
+ zoomName + '-out', container, this._zoomOut, this);
20
26
 
27
+ this._updateDisabled();
21
28
  map.on('zoomend zoomlevelschange', this._updateDisabled, this);
22
29
 
23
30
  return container;
@@ -48,7 +55,8 @@ L.Control.Zoom = L.Control.extend({
48
55
  .on(link, 'mousedown', stop)
49
56
  .on(link, 'dblclick', stop)
50
57
  .on(link, 'click', L.DomEvent.preventDefault)
51
- .on(link, 'click', fn, context);
58
+ .on(link, 'click', fn, context)
59
+ .on(link, 'click', this._refocusOnMap, context);
52
60
 
53
61
  return link;
54
62
  },
@@ -66,6 +66,12 @@ L.Control = L.Class.extend({
66
66
  }
67
67
 
68
68
  return this;
69
+ },
70
+
71
+ _refocusOnMap: function () {
72
+ if (this._map) {
73
+ this._map.getContainer().focus();
74
+ }
69
75
  }
70
76
  });
71
77
 
@@ -103,5 +109,9 @@ L.Map.include({
103
109
  createCorner('top', 'right');
104
110
  createCorner('bottom', 'left');
105
111
  createCorner('bottom', 'right');
112
+ },
113
+
114
+ _clearControlPos: function () {
115
+ this._container.removeChild(this._controlContainer);
106
116
  }
107
117
  });
@@ -1,4 +1,5 @@
1
1
  /*
2
2
  Leaflet, a JavaScript library for mobile-friendly interactive maps. http://leafletjs.com
3
- (c) 2010-2013, Vladimir Agafonkin, CloudMade
3
+ (c) 2010-2013, Vladimir Agafonkin
4
+ (c) 2010-2011, CloudMade
4
5
  */
@@ -4,9 +4,7 @@
4
4
 
5
5
  (function () {
6
6
 
7
- var ie = !!window.ActiveXObject,
8
- ie6 = ie && !window.XMLHttpRequest,
9
- ie7 = ie && !document.querySelector,
7
+ var ie = 'ActiveXObject' in window,
10
8
  ielt9 = ie && !document.addEventListener,
11
9
 
12
10
  // terrible browser detection to work around Safari / iOS / Android browser bugs
@@ -16,10 +14,13 @@
16
14
  phantomjs = ua.indexOf('phantom') !== -1,
17
15
  android = ua.indexOf('android') !== -1,
18
16
  android23 = ua.search('android [23]') !== -1,
17
+ gecko = ua.indexOf('gecko') !== -1,
19
18
 
20
19
  mobile = typeof orientation !== undefined + '',
21
- msTouch = window.navigator && window.navigator.msPointerEnabled &&
22
- window.navigator.msMaxTouchPoints,
20
+ msPointer = window.navigator && window.navigator.msPointerEnabled &&
21
+ window.navigator.msMaxTouchPoints && !window.PointerEvent,
22
+ pointer = (window.PointerEvent && window.navigator.pointerEnabled && window.navigator.maxTouchPoints) ||
23
+ msPointer,
23
24
  retina = ('devicePixelRatio' in window && window.devicePixelRatio > 1) ||
24
25
  ('matchMedia' in window && window.matchMedia('(min-resolution:144dpi)') &&
25
26
  window.matchMedia('(min-resolution:144dpi)').matches),
@@ -39,8 +40,8 @@
39
40
 
40
41
  var startName = 'ontouchstart';
41
42
 
42
- // IE10+ (We simulate these into touch* events in L.DomEvent and L.DomEvent.MsTouch) or WebKit, etc.
43
- if (msTouch || (startName in doc)) {
43
+ // IE10+ (We simulate these into touch* events in L.DomEvent and L.DomEvent.Pointer) or WebKit, etc.
44
+ if (pointer || (startName in doc)) {
44
45
  return true;
45
46
  }
46
47
 
@@ -66,10 +67,9 @@
66
67
 
67
68
  L.Browser = {
68
69
  ie: ie,
69
- ie6: ie6,
70
- ie7: ie7,
71
70
  ielt9: ielt9,
72
71
  webkit: webkit,
72
+ gecko: gecko && !webkit && !window.opera && !ie,
73
73
 
74
74
  android: android,
75
75
  android23: android23,
@@ -88,7 +88,8 @@
88
88
  mobileOpera: mobile && window.opera,
89
89
 
90
90
  touch: touch,
91
- msTouch: msTouch,
91
+ msPointer: msPointer,
92
+ pointer: pointer,
92
93
 
93
94
  retina: retina
94
95
  };
@@ -14,7 +14,7 @@ L.Mixin.Events = {
14
14
  if (L.Util.invokeEach(types, this.addEventListener, this, fn, context)) { return this; }
15
15
 
16
16
  var events = this[eventsKey] = this[eventsKey] || {},
17
- contextId = context && L.stamp(context),
17
+ contextId = context && context !== this && L.stamp(context),
18
18
  i, len, event, type, indexKey, indexLenKey, typeIndex;
19
19
 
20
20
  // types can be a string of space-separated words
@@ -27,12 +27,12 @@ L.Mixin.Events = {
27
27
  };
28
28
  type = types[i];
29
29
 
30
- if (context) {
30
+ if (contextId) {
31
31
  // store listeners of a particular context in a separate hash (if it has an id)
32
32
  // gives a major performance boost when removing thousands of map layers
33
33
 
34
- indexKey = type + '_idx',
35
- indexLenKey = indexKey + '_len',
34
+ indexKey = type + '_idx';
35
+ indexLenKey = indexKey + '_len';
36
36
 
37
37
  typeIndex = events[indexKey] = events[indexKey] || {};
38
38
 
@@ -74,8 +74,8 @@ L.Mixin.Events = {
74
74
  if (L.Util.invokeEach(types, this.removeEventListener, this, fn, context)) { return this; }
75
75
 
76
76
  var events = this[eventsKey],
77
- contextId = context && L.stamp(context),
78
- i, len, type, listeners, j, indexKey, indexLenKey, typeIndex;
77
+ contextId = context && context !== this && L.stamp(context),
78
+ i, len, type, listeners, j, indexKey, indexLenKey, typeIndex, removed;
79
79
 
80
80
  types = L.Util.splitWords(types);
81
81
 
@@ -90,14 +90,18 @@ L.Mixin.Events = {
90
90
  // clear all listeners for a type if function isn't specified
91
91
  delete events[type];
92
92
  delete events[indexKey];
93
+ delete events[indexLenKey];
93
94
 
94
95
  } else {
95
- listeners = context && typeIndex ? typeIndex[contextId] : events[type];
96
+ listeners = contextId && typeIndex ? typeIndex[contextId] : events[type];
96
97
 
97
98
  if (listeners) {
98
99
  for (j = listeners.length - 1; j >= 0; j--) {
99
100
  if ((listeners[j].action === fn) && (!context || (listeners[j].context === context))) {
100
- listeners.splice(j, 1);
101
+ removed = listeners.splice(j, 1);
102
+ // set the old action to a no-op, because it is possible
103
+ // that the listener is being iterated over as part of a dispatch
104
+ removed[0].action = L.Util.falseFn;
101
105
  }
102
106
  }
103
107
 
@@ -132,7 +136,7 @@ L.Mixin.Events = {
132
136
  listeners = events[type].slice();
133
137
 
134
138
  for (i = 0, len = listeners.length; i < len; i++) {
135
- listeners[i].action.call(listeners[i].context || this, event);
139
+ listeners[i].action.call(listeners[i].context, event);
136
140
  }
137
141
  }
138
142
 
@@ -140,11 +144,11 @@ L.Mixin.Events = {
140
144
  typeIndex = events[type + '_idx'];
141
145
 
142
146
  for (contextId in typeIndex) {
143
- listeners = typeIndex[contextId];
147
+ listeners = typeIndex[contextId].slice();
144
148
 
145
149
  if (listeners) {
146
150
  for (i = 0, len = listeners.length; i < len; i++) {
147
- listeners[i].action.call(listeners[i].context || this, event);
151
+ listeners[i].action.call(listeners[i].context, event);
148
152
  }
149
153
  }
150
154
  }
@@ -26,8 +26,9 @@ L.Util = {
26
26
  },
27
27
 
28
28
  stamp: (function () {
29
- var lastId = 0, key = '_leaflet_id';
30
- return function (/*Object*/ obj) {
29
+ var lastId = 0,
30
+ key = '_leaflet_id';
31
+ return function (obj) {
31
32
  obj[key] = obj[key] || ++lastId;
32
33
  return obj[key];
33
34
  };
@@ -96,27 +97,31 @@ L.Util = {
96
97
  return obj.options;
97
98
  },
98
99
 
99
- getParamString: function (obj, existingUrl) {
100
+ getParamString: function (obj, existingUrl, uppercase) {
100
101
  var params = [];
101
102
  for (var i in obj) {
102
- params.push(encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]));
103
+ params.push(encodeURIComponent(uppercase ? i.toUpperCase() : i) + '=' + encodeURIComponent(obj[i]));
103
104
  }
104
105
  return ((!existingUrl || existingUrl.indexOf('?') === -1) ? '?' : '&') + params.join('&');
105
106
  },
106
107
 
107
- template: function (str, data) {
108
- return str.replace(/\{ *([\w_]+) *\}/g, function (str, key) {
109
- var value = data[key];
110
- if (value === undefined) {
111
- throw new Error('No value provided for variable ' + str);
112
- } else if (typeof value === 'function') {
113
- value = value(data);
114
- }
115
- return value;
108
+ compileTemplate: function (str, data) {
109
+ // based on https://gist.github.com/padolsey/6008842
110
+ str = str.replace(/"/g, '\\\"');
111
+ str = str.replace(/\{ *([\w_]+) *\}/g, function (str, key) {
112
+ return '" + o["' + key + '"]' + (typeof data[key] === 'function' ? '(o)' : '') + ' + "';
116
113
  });
114
+ // jshint evil: true
115
+ return new Function('o', 'return "' + str + '";');
116
+ },
117
+
118
+ template: function (str, data) {
119
+ var cache = L.Util._templateCache = L.Util._templateCache || {};
120
+ cache[str] = cache[str] || L.Util.compileTemplate(str, data);
121
+ return cache[str](data);
117
122
  },
118
123
 
119
- isArray: function (obj) {
124
+ isArray: Array.isArray || function (obj) {
120
125
  return (Object.prototype.toString.call(obj) === '[object Array]');
121
126
  },
122
127