src/pyams_gis/resources/js/Draw/Leaflet.draw.js
changeset 75 a430cc4ae715
equal deleted inserted replaced
74:31687784fa16 75:a430cc4ae715
       
     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 /**
       
    52  * @class L.drawLocal
       
    53  * @aka L.drawLocal
       
    54  *
       
    55  * The core toolbar class of the API — it is used to create the toolbar ui
       
    56  *
       
    57  * @example
       
    58  * ```js
       
    59  *      var modifiedDraw = L.drawLocal.extend({
       
    60  *          draw: {
       
    61  *              toolbar: {
       
    62  *                  buttons: {
       
    63  *                      polygon: 'Draw an awesome polygon'
       
    64  *                  }
       
    65  *              }
       
    66  *          }
       
    67  *      });
       
    68  * ```
       
    69  *
       
    70  * The default state for the control is the draw toolbar just below the zoom control.
       
    71  *  This will allow map users to draw vectors and markers.
       
    72  *  **Please note the edit toolbar is not enabled by default.**
       
    73  */
       
    74 L.drawLocal = {
       
    75 	// format: {
       
    76 	// 	numeric: {
       
    77 	// 		delimiters: {
       
    78 	// 			thousands: ',',
       
    79 	// 			decimal: '.'
       
    80 	// 		}
       
    81 	// 	}
       
    82 	// },
       
    83 	draw: {
       
    84 		toolbar: {
       
    85 			// #TODO: this should be reorganized where actions are nested in actions
       
    86 			// ex: actions.undo  or actions.cancel
       
    87 			actions: {
       
    88 				title: 'Cancel drawing',
       
    89 				text: 'Cancel'
       
    90 			},
       
    91 			finish: {
       
    92 				title: 'Finish drawing',
       
    93 				text: 'Finish'
       
    94 			},
       
    95 			undo: {
       
    96 				title: 'Delete last point drawn',
       
    97 				text: 'Delete last point'
       
    98 			},
       
    99 			buttons: {
       
   100 				polyline: 'Draw a polyline',
       
   101 				polygon: 'Draw a polygon',
       
   102 				rectangle: 'Draw a rectangle',
       
   103 				circle: 'Draw a circle',
       
   104 				marker: 'Draw a marker',
       
   105 				circlemarker: 'Draw a circlemarker'
       
   106 			}
       
   107 		},
       
   108 		handlers: {
       
   109 			circle: {
       
   110 				tooltip: {
       
   111 					start: 'Click and drag to draw circle.'
       
   112 				},
       
   113 				radius: 'Radius'
       
   114 			},
       
   115 			circlemarker: {
       
   116 				tooltip: {
       
   117 					start: 'Click map to place circle marker.'
       
   118 				}
       
   119 			},
       
   120 			marker: {
       
   121 				tooltip: {
       
   122 					start: 'Click map to place marker.'
       
   123 				}
       
   124 			},
       
   125 			polygon: {
       
   126 				tooltip: {
       
   127 					start: 'Click to start drawing shape.',
       
   128 					cont: 'Click to continue drawing shape.',
       
   129 					end: 'Click first point to close this shape.'
       
   130 				}
       
   131 			},
       
   132 			polyline: {
       
   133 				error: '<strong>Error:</strong> shape edges cannot cross!',
       
   134 				tooltip: {
       
   135 					start: 'Click to start drawing line.',
       
   136 					cont: 'Click to continue drawing line.',
       
   137 					end: 'Click last point to finish line.'
       
   138 				}
       
   139 			},
       
   140 			rectangle: {
       
   141 				tooltip: {
       
   142 					start: 'Click and drag to draw rectangle.'
       
   143 				}
       
   144 			},
       
   145 			simpleshape: {
       
   146 				tooltip: {
       
   147 					end: 'Release mouse to finish drawing.'
       
   148 				}
       
   149 			}
       
   150 		}
       
   151 	},
       
   152 	edit: {
       
   153 		toolbar: {
       
   154 			actions: {
       
   155 				save: {
       
   156 					title: 'Save changes',
       
   157 					text: 'Save'
       
   158 				},
       
   159 				cancel: {
       
   160 					title: 'Cancel editing, discards all changes',
       
   161 					text: 'Cancel'
       
   162 				},
       
   163 				clearAll: {
       
   164 					title: 'Clear all layers',
       
   165 					text: 'Clear All'
       
   166 				}
       
   167 			},
       
   168 			buttons: {
       
   169 				edit: 'Edit layers',
       
   170 				editDisabled: 'No layers to edit',
       
   171 				remove: 'Delete layers',
       
   172 				removeDisabled: 'No layers to delete'
       
   173 			}
       
   174 		},
       
   175 		handlers: {
       
   176 			edit: {
       
   177 				tooltip: {
       
   178 					text: 'Drag handles or markers to edit features.',
       
   179 					subtext: 'Click cancel to undo changes.'
       
   180 				}
       
   181 			},
       
   182 			remove: {
       
   183 				tooltip: {
       
   184 					text: 'Click on a feature to remove.'
       
   185 				}
       
   186 			}
       
   187 		}
       
   188 	}
       
   189 };