Leaflet.draw.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /**
  2. * Leaflet.draw assumes that you have already included the Leaflet library.
  3. */
  4. L.drawVersion = '0.4.2';
  5. /**
  6. * @class L.Draw
  7. * @aka Draw
  8. *
  9. *
  10. * To add the draw toolbar set the option drawControl: true in the map options.
  11. *
  12. * @example
  13. * ```js
  14. * var map = L.map('map', {drawControl: true}).setView([51.505, -0.09], 13);
  15. *
  16. * L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
  17. * attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
  18. * }).addTo(map);
  19. * ```
  20. *
  21. * ### Adding the edit toolbar
  22. * To use the edit toolbar you must initialise the Leaflet.draw control and manually add it to the map.
  23. *
  24. * ```js
  25. * var map = L.map('map').setView([51.505, -0.09], 13);
  26. *
  27. * L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
  28. * attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
  29. * }).addTo(map);
  30. *
  31. * // FeatureGroup is to store editable layers
  32. * var drawnItems = new L.FeatureGroup();
  33. * map.addLayer(drawnItems);
  34. *
  35. * var drawControl = new L.Control.Draw({
  36. * edit: {
  37. * featureGroup: drawnItems
  38. * }
  39. * });
  40. * map.addControl(drawControl);
  41. * ```
  42. *
  43. * The key here is the featureGroup option. This tells the plugin which FeatureGroup contains the layers that
  44. * should be editable. The featureGroup can contain 0 or more features with geometry types Point, LineString, and Polygon.
  45. * Leaflet.draw does not work with multigeometry features such as MultiPoint, MultiLineString, MultiPolygon,
  46. * or GeometryCollection. If you need to add multigeometry features to the draw plugin, convert them to a
  47. * FeatureCollection of non-multigeometries (Points, LineStrings, or Polygons).
  48. */
  49. L.Draw = {};
  50. /**
  51. * @class L.drawLocal
  52. * @aka L.drawLocal
  53. *
  54. * The core toolbar class of the API — it is used to create the toolbar ui
  55. *
  56. * @example
  57. * ```js
  58. * var modifiedDraw = L.drawLocal.extend({
  59. * draw: {
  60. * toolbar: {
  61. * buttons: {
  62. * polygon: 'Draw an awesome polygon'
  63. * }
  64. * }
  65. * }
  66. * });
  67. * ```
  68. *
  69. * The default state for the control is the draw toolbar just below the zoom control.
  70. * This will allow map users to draw vectors and markers.
  71. * **Please note the edit toolbar is not enabled by default.**
  72. */
  73. L.drawLocal = {
  74. // format: {
  75. // numeric: {
  76. // delimiters: {
  77. // thousands: ',',
  78. // decimal: '.'
  79. // }
  80. // }
  81. // },
  82. draw: {
  83. toolbar: {
  84. // #TODO: this should be reorganized where actions are nested in actions
  85. // ex: actions.undo or actions.cancel
  86. actions: {
  87. title: 'Cancel drawing',
  88. text: 'Cancel'
  89. },
  90. finish: {
  91. title: 'Finish drawing',
  92. text: 'Finish'
  93. },
  94. undo: {
  95. title: 'Delete last point drawn',
  96. text: 'Delete last point'
  97. },
  98. buttons: {
  99. polyline: 'Draw a polyline',
  100. polygon: 'Draw a polygon',
  101. rectangle: 'Draw a rectangle',
  102. circle: 'Draw a circle',
  103. marker: 'Draw a marker'
  104. }
  105. },
  106. handlers: {
  107. circle: {
  108. tooltip: {
  109. start: 'Click and drag to draw circle.'
  110. },
  111. radius: 'Radius'
  112. },
  113. marker: {
  114. tooltip: {
  115. start: 'Click map to place marker.'
  116. }
  117. },
  118. polygon: {
  119. tooltip: {
  120. start: 'Click to start drawing shape.',
  121. cont: 'Click to continue drawing shape.',
  122. end: 'Click first point to close this shape.'
  123. }
  124. },
  125. polyline: {
  126. error: '<strong>Error:</strong> shape edges cannot cross!',
  127. tooltip: {
  128. start: 'Click to start drawing line.',
  129. cont: 'Click to continue drawing line.',
  130. end: 'Click last point to finish line.'
  131. }
  132. },
  133. rectangle: {
  134. tooltip: {
  135. start: 'Click and drag to draw rectangle.'
  136. }
  137. },
  138. simpleshape: {
  139. tooltip: {
  140. end: 'Release mouse to finish drawing.'
  141. }
  142. }
  143. }
  144. },
  145. edit: {
  146. toolbar: {
  147. actions: {
  148. save: {
  149. title: 'Save changes.',
  150. text: 'Save'
  151. },
  152. cancel: {
  153. title: 'Cancel editing, discards all changes.',
  154. text: 'Cancel'
  155. },
  156. clearAll:{
  157. title: 'clear all layers.',
  158. text: 'Clear All'
  159. }
  160. },
  161. buttons: {
  162. edit: 'Edit layers.',
  163. editDisabled: 'No layers to edit.',
  164. remove: 'Delete layers.',
  165. removeDisabled: 'No layers to delete.'
  166. }
  167. },
  168. handlers: {
  169. edit: {
  170. tooltip: {
  171. text: 'Drag handles, or marker to edit feature.',
  172. subtext: 'Click cancel to undo changes.'
  173. }
  174. },
  175. remove: {
  176. tooltip: {
  177. text: 'Click on a feature to remove'
  178. }
  179. }
  180. }
  181. }
  182. };