vendor: 2,584 bytes, lines 1-110
1/** 2 * @class L.Draw.Polygon 3 * @aka Draw.Polygon 4 * @inherits L.Draw.Polyline 5 */ 6L.Draw.Polygon = L.Draw.Polyline.extend({ 7 statics: { 8 TYPE: 'polygon' 9 }, 10 11 Poly: L.Polygon, 12 13 options: { 14 showArea: false, 15 shapeOptions: { 16 stroke: true, 17 color: '#3388ff', 18 weight: 4, 19 opacity: 0.5, 20 fill: true, 21 fillColor: null, //same as color by default 22 fillOpacity: 0.2, 23 clickable: true 24 }, 25 metric: true // Whether to use the metric measurement system or imperial 26 }, 27 28 // @method initialize(): void 29 initialize: function (map, options) { 30 L.Draw.Polyline.prototype.initialize.call(this, map, options); 31 32 // Save the type so super can fire, need to do this as cannot do this.TYPE :( 33 this.type = L.Draw.Polygon.TYPE; 34 }, 35 36 _updateFinishHandler: function () { 37 var markerCount = this._markers.length; 38 39 // The first marker should have a click handler to close the polygon 40 if (markerCount === 1) { 41 this._markers[0].on('click', this._finishShape, this); 42 } 43 44 // Add and update the double click handler 45 if (markerCount > 2) { 46 this._markers[markerCount - 1].on('dblclick', this._finishShape, this); 47 // Only need to remove handler if has been added before 48 if (markerCount > 3) { 49 this._markers[markerCount - 2].off('dblclick', this._finishShape, this); 50 } 51 } 52 }, 53 54 _getTooltipText: function () { 55 var text, subtext; 56 57 if (this._markers.length === 0) { 58 text = L.drawLocal.draw.handlers.polygon.tooltip.start; 59 } else if (this._markers.length < 3) { 60 text = L.drawLocal.draw.handlers.polygon.tooltip.cont; 61 } else { 62 text = L.drawLocal.draw.handlers.polygon.tooltip.end; 63 subtext = this._getMeasurementString(); 64 } 65 66 return { 67 text: text, 68 subtext: subtext 69 }; 70 }, 71 72 _getMeasurementString: function () { 73 var area = this._area; 74 75 if (!area) { 76 return null; 77 } 78 79 return L.GeometryUtil.readableArea(area, this.options.metric); 80 }, 81 82 _shapeIsValid: function () { 83 return this._markers.length >= 3; 84 }, 85 86 _vertexChanged: function (latlng, added) { 87 var latLngs; 88 89 // Check to see if we should show the area 90 if (!this.options.allowIntersection && this.options.showArea) { 91 latLngs = this._poly.getLatLngs(); 92 93 this._area = L.GeometryUtil.geodesicArea(latLngs); 94 } 95 96 L.Draw.Polyline.prototype._vertexChanged.call(this, latlng, added); 97 }, 98 99 _cleanUpShape: function () { 100 var markerCount = this._markers.length; 101 102 if (markerCount > 0) { 103 this._markers[0].off('click', this._finishShape, this); 104 105 if (markerCount > 2) { 106 this._markers[markerCount - 1].off('dblclick', this._finishShape, this); 107 } 108 } 109 } 110});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.