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
@@ -45,7 +45,7 @@ L.Toolbar = L.Class.extend({
45
45
  this._actionsContainer = null;
46
46
  },
47
47
 
48
- _initModeHandler: function (handler, container, buttonIndex, classNamePredix) {
48
+ _initModeHandler: function (handler, container, buttonIndex, classNamePredix, buttonTitle) {
49
49
  var type = handler.type;
50
50
 
51
51
  this._modes[type] = {};
@@ -53,7 +53,7 @@ L.Toolbar = L.Class.extend({
53
53
  this._modes[type].handler = handler;
54
54
 
55
55
  this._modes[type].button = this._createButton({
56
- title: this.options[type].title,
56
+ title: buttonTitle,
57
57
  className: classNamePredix + '-' + type,
58
58
  container: container,
59
59
  callback: this._modes[type].handler.enable,
@@ -126,9 +126,7 @@ L.Toolbar = L.Class.extend({
126
126
 
127
127
  _createActions: function (buttons) {
128
128
  var container = L.DomUtil.create('ul', 'leaflet-draw-actions'),
129
- buttonWidth = 50,
130
129
  l = buttons.length,
131
- containerWidth = (l * buttonWidth) + (l - 1), //l - 1 = the borders
132
130
  li, button;
133
131
 
134
132
  for (var i = 0; i < l; i++) {
@@ -148,8 +146,6 @@ L.Toolbar = L.Class.extend({
148
146
  });
149
147
  }
150
148
 
151
- container.style.width = containerWidth + 'px';
152
-
153
149
  return container;
154
150
  },
155
151
 
@@ -3,16 +3,21 @@ L.Tooltip = L.Class.extend({
3
3
  this._map = map;
4
4
  this._popupPane = map._panes.popupPane;
5
5
 
6
- this._container = L.DomUtil.create('div', 'leaflet-draw-tooltip', this._popupPane);
6
+ this._container = map.options.drawControlTooltips ? L.DomUtil.create('div', 'leaflet-draw-tooltip', this._popupPane) : null;
7
7
  this._singleLineLabel = false;
8
8
  },
9
9
 
10
10
  dispose: function () {
11
- this._popupPane.removeChild(this._container);
12
- this._container = null;
11
+ if (this._container) {
12
+ this._popupPane.removeChild(this._container);
13
+ this._container = null;
14
+ }
13
15
  },
14
16
 
15
17
  updateContent: function (labelText) {
18
+ if (!this._container) {
19
+ return this;
20
+ }
16
21
  labelText.subtext = labelText.subtext || '';
17
22
 
18
23
  // update the vertical position (only if changed)
@@ -33,20 +38,28 @@ L.Tooltip = L.Class.extend({
33
38
  },
34
39
 
35
40
  updatePosition: function (latlng) {
36
- var pos = this._map.latLngToLayerPoint(latlng);
41
+ var pos = this._map.latLngToLayerPoint(latlng),
42
+ tooltipContainer = this._container;
37
43
 
38
- L.DomUtil.setPosition(this._container, pos);
44
+ if (this._container) {
45
+ tooltipContainer.style.visibility = 'inherit';
46
+ L.DomUtil.setPosition(tooltipContainer, pos);
47
+ }
39
48
 
40
49
  return this;
41
50
  },
42
51
 
43
52
  showAsError: function () {
44
- L.DomUtil.addClass(this._container, 'leaflet-error-draw-tooltip');
53
+ if (this._container) {
54
+ L.DomUtil.addClass(this._container, 'leaflet-error-draw-tooltip');
55
+ }
45
56
  return this;
46
57
  },
47
58
 
48
59
  removeError: function () {
49
- L.DomUtil.removeClass(this._container, 'leaflet-error-draw-tooltip');
60
+ if (this._container) {
61
+ L.DomUtil.removeClass(this._container, 'leaflet-error-draw-tooltip');
62
+ }
50
63
  return this;
51
64
  }
52
65
  });
@@ -1,24 +1,23 @@
1
1
  L.DrawToolbar = L.Toolbar.extend({
2
2
 
3
3
  options: {
4
- polyline: {
5
- title: 'Draw a polyline'
6
- },
7
- polygon: {
8
- title: 'Draw a polygon'
9
- },
10
- rectangle: {
11
- title: 'Draw a rectangle'
12
- },
13
- circle: {
14
- title: 'Draw a circle'
15
- },
16
- marker: {
17
- title: 'Add a marker'
18
- }
4
+ polyline: {},
5
+ polygon: {},
6
+ rectangle: {},
7
+ circle: {},
8
+ marker: {}
19
9
  },
20
10
 
21
11
  initialize: function (options) {
12
+ // Ensure that the options are merged correctly since L.extend is only shallow
13
+ for (var type in this.options) {
14
+ if (this.options.hasOwnProperty(type)) {
15
+ if (options[type]) {
16
+ options[type] = L.extend({}, this.options[type], options[type]);
17
+ }
18
+ }
19
+ }
20
+
22
21
  L.Toolbar.prototype.initialize.call(this, options);
23
22
  },
24
23
 
@@ -35,7 +34,8 @@ L.DrawToolbar = L.Toolbar.extend({
35
34
  new L.Draw.Polyline(map, this.options.polyline),
36
35
  this._toolbarContainer,
37
36
  buttonIndex++,
38
- buttonClassPrefix
37
+ buttonClassPrefix,
38
+ L.drawLocal.draw.toolbar.buttons.polyline
39
39
  );
40
40
  }
41
41
 
@@ -44,7 +44,8 @@ L.DrawToolbar = L.Toolbar.extend({
44
44
  new L.Draw.Polygon(map, this.options.polygon),
45
45
  this._toolbarContainer,
46
46
  buttonIndex++,
47
- buttonClassPrefix
47
+ buttonClassPrefix,
48
+ L.drawLocal.draw.toolbar.buttons.polygon
48
49
  );
49
50
  }
50
51
 
@@ -53,7 +54,8 @@ L.DrawToolbar = L.Toolbar.extend({
53
54
  new L.Draw.Rectangle(map, this.options.rectangle),
54
55
  this._toolbarContainer,
55
56
  buttonIndex++,
56
- buttonClassPrefix
57
+ buttonClassPrefix,
58
+ L.drawLocal.draw.toolbar.buttons.rectangle
57
59
  );
58
60
  }
59
61
 
@@ -62,7 +64,8 @@ L.DrawToolbar = L.Toolbar.extend({
62
64
  new L.Draw.Circle(map, this.options.circle),
63
65
  this._toolbarContainer,
64
66
  buttonIndex++,
65
- buttonClassPrefix
67
+ buttonClassPrefix,
68
+ L.drawLocal.draw.toolbar.buttons.circle
66
69
  );
67
70
  }
68
71
 
@@ -71,7 +74,8 @@ L.DrawToolbar = L.Toolbar.extend({
71
74
  new L.Draw.Marker(map, this.options.marker),
72
75
  this._toolbarContainer,
73
76
  buttonIndex++,
74
- buttonClassPrefix
77
+ buttonClassPrefix,
78
+ L.drawLocal.draw.toolbar.buttons.marker
75
79
  );
76
80
  }
77
81
 
@@ -81,8 +85,8 @@ L.DrawToolbar = L.Toolbar.extend({
81
85
  // Create the actions part of the toolbar
82
86
  this._actionsContainer = this._createActions([
83
87
  {
84
- title: 'Cancel drawing',
85
- text: 'Cancel',
88
+ title: L.drawLocal.draw.toolbar.actions.title,
89
+ text: L.drawLocal.draw.toolbar.actions.text,
86
90
  callback: this.disable,
87
91
  context: this
88
92
  }
@@ -13,18 +13,20 @@ L.Draw.Circle = L.Draw.SimpleShape.extend({
13
13
  fillColor: null, //same as color by default
14
14
  fillOpacity: 0.2,
15
15
  clickable: true
16
- }
16
+ },
17
+ showRadius: true,
18
+ metric: true // Whether to use the metric meaurement system or imperial
17
19
  },
18
20
 
19
21
  initialize: function (map, options) {
20
22
  // Save the type so super can fire, need to do this as cannot do this.TYPE :(
21
23
  this.type = L.Draw.Circle.TYPE;
22
24
 
25
+ this._initialLabelText = L.drawLocal.draw.handlers.circle.tooltip.start;
26
+
23
27
  L.Draw.SimpleShape.prototype.initialize.call(this, map, options);
24
28
  },
25
29
 
26
- _initialLabelText: 'Click and drag to draw circle.',
27
-
28
30
  _drawShape: function (latlng) {
29
31
  if (!this._shape) {
30
32
  this._shape = new L.Circle(this._startLatLng, this._startLatLng.distanceTo(latlng), this.options.shapeOptions);
@@ -41,6 +43,9 @@ L.Draw.Circle = L.Draw.SimpleShape.extend({
41
43
 
42
44
  _onMouseMove: function (e) {
43
45
  var latlng = e.latlng,
46
+ metric = this.options.metric,
47
+ showRadius = this.options.showRadius,
48
+ useMetric = this.options.metric,
44
49
  radius;
45
50
 
46
51
  this._tooltip.updatePosition(latlng);
@@ -51,9 +56,9 @@ L.Draw.Circle = L.Draw.SimpleShape.extend({
51
56
  radius = this._shape.getRadius().toFixed(1);
52
57
 
53
58
  this._tooltip.updateContent({
54
- text: 'Release mouse to finish drawing.',
55
- subtext: 'Radius: ' + radius + ' m'
59
+ text: this._endLabelText,
60
+ subtext: showRadius ? 'Radius: ' + L.GeometryUtil.readableDistance(radius, useMetric) : ''
56
61
  });
57
62
  }
58
63
  }
59
- });
64
+ });
@@ -13,7 +13,7 @@ L.Draw.Feature = L.Handler.extend({
13
13
  if (options && options.shapeOptions) {
14
14
  options.shapeOptions = L.Util.extend({}, this.options.shapeOptions, options.shapeOptions);
15
15
  }
16
- L.Util.extend(this.options, options);
16
+ L.setOptions(this, options);
17
17
  },
18
18
 
19
19
  enable: function () {
@@ -37,9 +37,13 @@ L.Draw.Feature = L.Handler.extend({
37
37
  },
38
38
 
39
39
  addHooks: function () {
40
- if (this._map) {
40
+ var map = this._map;
41
+
42
+ if (map) {
41
43
  L.DomUtil.disableTextSelection();
42
44
 
45
+ map.getContainer().focus();
46
+
43
47
  this._tooltip = new L.Tooltip(this._map);
44
48
 
45
49
  L.DomEvent.addListener(this._container, 'keyup', this._cancelDrawing, this);
@@ -5,6 +5,7 @@ L.Draw.Marker = L.Draw.Feature.extend({
5
5
 
6
6
  options: {
7
7
  icon: new L.Icon.Default(),
8
+ repeatMode: false,
8
9
  zIndexOffset: 2000 // This should be > than the highest z-index any markers
9
10
  },
10
11
 
@@ -19,7 +20,7 @@ L.Draw.Marker = L.Draw.Feature.extend({
19
20
  L.Draw.Feature.prototype.addHooks.call(this);
20
21
 
21
22
  if (this._map) {
22
- this._tooltip.updateContent({ text: 'Click map to place marker.' });
23
+ this._tooltip.updateContent({ text: L.drawLocal.draw.handlers.marker.tooltip.start });
23
24
 
24
25
  // Same mouseMarker as in Draw.Polyline
25
26
  if (!this._mouseMarker) {
@@ -80,6 +81,7 @@ L.Draw.Marker = L.Draw.Feature.extend({
80
81
  .addLayer(this._marker);
81
82
  }
82
83
  else {
84
+ latlng = this._mouseMarker.getLatLng();
83
85
  this._marker.setLatLng(latlng);
84
86
  }
85
87
  },
@@ -88,10 +90,13 @@ L.Draw.Marker = L.Draw.Feature.extend({
88
90
  this._fireCreatedEvent();
89
91
 
90
92
  this.disable();
93
+ if (this.options.repeatMode) {
94
+ this.enable();
95
+ }
91
96
  },
92
97
 
93
98
  _fireCreatedEvent: function () {
94
99
  var marker = new L.Marker(this._marker.getLatLng(), { icon: this.options.icon });
95
100
  L.Draw.Feature.prototype._fireCreatedEvent.call(this, marker);
96
101
  }
97
- });
102
+ });
@@ -6,6 +6,7 @@ L.Draw.Polygon = L.Draw.Polyline.extend({
6
6
  Poly: L.Polygon,
7
7
 
8
8
  options: {
9
+ showArea: false,
9
10
  shapeOptions: {
10
11
  stroke: true,
11
12
  color: '#f06eaa',
@@ -44,25 +45,46 @@ L.Draw.Polygon = L.Draw.Polyline.extend({
44
45
  },
45
46
 
46
47
  _getTooltipText: function () {
47
- var text;
48
+ var text, subtext;
49
+
48
50
  if (this._markers.length === 0) {
49
- text = 'Click to start drawing shape.';
51
+ text = L.drawLocal.draw.handlers.polygon.tooltip.start;
50
52
  } else if (this._markers.length < 3) {
51
- text = 'Click to continue drawing shape.';
53
+ text = L.drawLocal.draw.handlers.polygon.tooltip.cont;
52
54
  } else {
53
- text = 'Double click to close this shape.';
55
+ text = L.drawLocal.draw.handlers.polygon.tooltip.end;
56
+ subtext = this._getMeasurementString();
54
57
  }
58
+
55
59
  return {
56
- text: text
60
+ text: text,
61
+ subtext: subtext
57
62
  };
58
63
  },
59
64
 
65
+ _getMeasurementString: function () {
66
+ var area = this._area;
67
+
68
+ if (!area) {
69
+ return null;
70
+ }
71
+
72
+ return L.GeometryUtil.readableArea(area, this.options.metric);
73
+ },
74
+
60
75
  _shapeIsValid: function () {
61
76
  return this._markers.length >= 3;
62
77
  },
63
78
 
64
79
  _vertexAdded: function () {
65
- //calc area here
80
+ // Check to see if we should show the area
81
+ if (this.options.allowIntersection || !this.options.showArea) {
82
+ return;
83
+ }
84
+
85
+ var latLngs = this._poly.getLatLngs();
86
+
87
+ this._area = L.GeometryUtil.geodesicArea(latLngs);
66
88
  },
67
89
 
68
90
  _cleanUpShape: function () {
@@ -76,4 +98,4 @@ L.Draw.Polygon = L.Draw.Polyline.extend({
76
98
  }
77
99
  }
78
100
  }
79
- });
101
+ });
@@ -7,9 +7,9 @@ L.Draw.Polyline = L.Draw.Feature.extend({
7
7
 
8
8
  options: {
9
9
  allowIntersection: true,
10
+ repeatMode: false,
10
11
  drawError: {
11
12
  color: '#b00b00',
12
- message: '<strong>Error:</strong> shape edges cannot cross!',
13
13
  timeout: 2500
14
14
  },
15
15
  icon: new L.DivIcon({
@@ -25,10 +25,15 @@ L.Draw.Polyline = L.Draw.Feature.extend({
25
25
  fill: false,
26
26
  clickable: true
27
27
  },
28
+ metric: true, // Whether to use the metric meaurement system or imperial
29
+ showLength: true, // Whether to display distance in the tooltip
28
30
  zIndexOffset: 2000 // This should be > than the highest z-index any map layers
29
31
  },
30
32
 
31
33
  initialize: function (map, options) {
34
+ // Need to set this here to ensure the correct message is used.
35
+ this.options.drawError.message = L.drawLocal.draw.handlers.polyline.error;
36
+
32
37
  // Merge default drawError options with custom options
33
38
  if (options && options.drawError) {
34
39
  options.drawError = L.Util.extend({}, this.options.drawError, options.drawError);
@@ -116,6 +121,9 @@ L.Draw.Polyline = L.Draw.Feature.extend({
116
121
 
117
122
  this._fireCreatedEvent();
118
123
  this.disable();
124
+ if (this.options.repeatMode) {
125
+ this.enable();
126
+ }
119
127
  },
120
128
 
121
129
  //Called to verify the shape is valid when the user tries to finish it
@@ -136,8 +144,7 @@ L.Draw.Polyline = L.Draw.Feature.extend({
136
144
  // should this be moved to _updateGuide() ?
137
145
  this._currentLatLng = latlng;
138
146
 
139
- // Update the label
140
- this._tooltip.updatePosition(latlng);
147
+ this._updateTooltip(latlng);
141
148
 
142
149
  // Update the guide line
143
150
  this._updateGuide(newPos);
@@ -173,6 +180,8 @@ L.Draw.Polyline = L.Draw.Feature.extend({
173
180
  this._vertexAdded(latlng);
174
181
 
175
182
  this._clearGuides();
183
+
184
+ this._updateTooltip();
176
185
  },
177
186
 
178
187
  _updateFinishHandler: function () {
@@ -200,15 +209,10 @@ L.Draw.Polyline = L.Draw.Feature.extend({
200
209
  },
201
210
 
202
211
  _updateGuide: function (newPos) {
203
- newPos = newPos || this._map.latLngToLayerPoint(this._currentLatLng);
204
-
205
212
  var markerCount = this._markers.length;
206
213
 
207
214
  if (markerCount > 0) {
208
- // Update the tooltip text, as long it's not showing and error
209
- if (!this._errorShown) {
210
- this._tooltip.updateContent(this._getTooltipText());
211
- }
215
+ newPos = newPos || this._map.latLngToLayerPoint(this._currentLatLng);
212
216
 
213
217
  // draw the guide line
214
218
  this._clearGuides();
@@ -219,6 +223,18 @@ L.Draw.Polyline = L.Draw.Feature.extend({
219
223
  }
220
224
  },
221
225
 
226
+ _updateTooltip: function (latLng) {
227
+ var text = this._getTooltipText();
228
+
229
+ if (latLng) {
230
+ this._tooltip.updatePosition(latLng);
231
+ }
232
+
233
+ if (!this._errorShown) {
234
+ this._tooltip.updateContent(text);
235
+ }
236
+ },
237
+
222
238
  _drawGuide: function (pointA, pointB) {
223
239
  var length = Math.floor(Math.sqrt(Math.pow((pointB.x - pointA.x), 2) + Math.pow((pointB.y - pointA.y), 2))),
224
240
  i,
@@ -269,28 +285,24 @@ L.Draw.Polyline = L.Draw.Feature.extend({
269
285
  },
270
286
 
271
287
  _getTooltipText: function () {
272
- var labelText,
273
- distance,
274
- distanceStr;
288
+ var showLength = this.options.showLength,
289
+ labelText, distance, distanceStr;
275
290
 
276
291
  if (this._markers.length === 0) {
277
292
  labelText = {
278
- text: 'Click to start drawing line.'
293
+ text: L.drawLocal.draw.handlers.polyline.tooltip.start
279
294
  };
280
295
  } else {
281
- // calculate the distance from the last fixed point to the mouse position
282
- distance = this._measurementRunningTotal + this._currentLatLng.distanceTo(this._markers[this._markers.length - 1].getLatLng());
283
- // show metres when distance is < 1km, then show km
284
- distanceStr = distance > 1000 ? (distance / 1000).toFixed(2) + ' km' : Math.ceil(distance) + ' m';
296
+ distanceStr = showLength ? this._getMeasurementString() : '';
285
297
 
286
298
  if (this._markers.length === 1) {
287
299
  labelText = {
288
- text: 'Click to continue drawing line.',
300
+ text: L.drawLocal.draw.handlers.polyline.tooltip.cont,
289
301
  subtext: distanceStr
290
302
  };
291
303
  } else {
292
304
  labelText = {
293
- text: 'Click last point to finish line.',
305
+ text: L.drawLocal.draw.handlers.polyline.tooltip.end,
294
306
  subtext: distanceStr
295
307
  };
296
308
  }
@@ -298,6 +310,17 @@ L.Draw.Polyline = L.Draw.Feature.extend({
298
310
  return labelText;
299
311
  },
300
312
 
313
+ _getMeasurementString: function () {
314
+ var currentLatLng = this._currentLatLng,
315
+ previousLatLng = this._markers[this._markers.length - 1].getLatLng(),
316
+ distance;
317
+
318
+ // calculate the distance from the last fixed point to the mouse position
319
+ distance = this._measurementRunningTotal + currentLatLng.distanceTo(previousLatLng);
320
+
321
+ return L.GeometryUtil.readableDistance(distance, this.options.metric);
322
+ },
323
+
301
324
  _showErrorTooltip: function () {
302
325
  this._errorShown = true;
303
326
 
@@ -348,7 +371,7 @@ L.Draw.Polyline = L.Draw.Feature.extend({
348
371
  },
349
372
 
350
373
  _cleanUpShape: function () {
351
- if (this._markers.length > 0) {
374
+ if (this._markers.length > 1) {
352
375
  this._markers[this._markers.length - 1].off('click', this._finishShape, this);
353
376
  }
354
377
  },
@@ -357,4 +380,4 @@ L.Draw.Polyline = L.Draw.Feature.extend({
357
380
  var poly = new this.Poly(this._poly.getLatLngs(), this.options.shapeOptions);
358
381
  L.Draw.Feature.prototype._fireCreatedEvent.call(this, poly);
359
382
  }
360
- });
383
+ });