1"use strict"; 2 3L.SVGPathBuilder = L.Class.extend({ 4 initialize: function(points, innerPoints, options) { 5 this._points = points || []; 6 this._innerPoints = innerPoints || []; 7 L.Util.setOptions(this, options); 8 }, 9 options: { 10 closePath: true 11 }, 12 _getPathString: function(points, digits) { 13 var pathString = "", 14 move = "M", lineTo = "L", close = "Z", 15 p, i = 0; 16 17 if (points.length) { 18 digits = digits !== null ? digits : 2; 19 20 if (L.Browser.vml) { 21 digits = 0; 22 move = "m"; 23 lineTo = "|"; 24 close = "xe"; 25 } 26 27 p = points[0]; 28 29 pathString = move + p.x.toFixed(digits) + "," + p.y.toFixed(digits); 30 31 while(p = points[++i]) { 32 pathString += lineTo + p.x.toFixed(digits) + "," + p.y.toFixed(digits); 33 } 34 35 pathString += this.options.closePath ? close : ""; 36 37 } 38 return pathString; 39 }, 40 41 addPoint: function(point, inner) { 42 inner ? this._innerPoints.push(point) : this._points.push(point); 43 }, 44 build: function(digits) { 45 digits = digits || this.options.digits; 46 var pathString = this._getPathString(this._points, digits); 47 if (this._innerPoints) { 48 pathString += this._getPathString(this._innerPoints, digits); 49 } 50 return pathString; 51 } 52}); 53 54L.RegularPolygonMarker = L.Path.extend({ 55 initialize: function(centerLatLng, options) { 56 L.Path.prototype.initialize.call(this, options); 57 this._latlng = centerLatLng; 58 this.options.numberOfSides = Math.max(this.options.numberOfSides, 3); 59 }, 60 options: { 61 fill: true, 62 radiusX: 10, 63 radiusY: 10, 64 rotation: 0, 65 numberOfSides: 3, 66 position: { 67 x: 0, 68 y: 0 69 }, 70 maxDegrees: 360, 71 gradient: true, 72 dropShadow: false 73 }, 74 setLatLng: function(latlng) { 75 this._latlng = latlng; 76 return this.redraw(); 77 }, 78 projectLatlngs: function() { 79 this._point = this._map.latLngToLayerPoint(this._latlng); 80 this._points = this._getPoints(); 81 if (this.options.innerRadius || this.options.innerRadiusX && this.options.innerRadiusY) { 82 this._innerPoints = this._getPoints(true).reverse(); 83 } 84 }, 85 getBounds: function() { 86 var map = this._map, radiusX = this.options.radius || this.options.radiusX, radiusY = this.options.radius || this.options.radiusY, deltaX = radiusX * Math.cos(Math.PI / 4), deltaY = radiusY * Math.sin(Math.PI / 4), point = map.project(this._latlng), swPoint = new L.Point(point.x - deltaX, point.y + deltaY), nePoint = new L.Point(point.x + deltaX, point.y - deltaY), sw = map.unproject(swPoint), ne = map.unproject(nePoint); 87 return new L.LatLngBounds(sw, ne); 88 }, 89 getLatLng: function() { 90 return this._latlng; 91 }, 92 getPathString: function() { 93 this._path.setAttribute("shape-rendering", "geometricPrecision"); 94 return new L.SVGPathBuilder(this._points, this._innerPoints).build(6); 95 }, 96 _getPoints: function(inner) { 97 var maxDegrees = this.options.maxDegrees || 360, 98 angleSize = maxDegrees / Math.max(this.options.numberOfSides, 3), 99 degrees = maxDegrees + this.options.rotation, 100 angle = this.options.rotation, 101 points = [], 102 radiusX = !inner ? this.options.radius || this.options.radiusX : this.options.innerRadius || this.options.innerRadiusX, 103 radiusY = !inner ? this.options.radius || this.options.radiusY : this.options.innerRadius || this.options.innerRadiusY; 104 105 while (angle < degrees) { 106 points.push(this._getPoint( 107 angle * Math.PI / 180, 108 radiusX, 109 radiusY 110 )); 111 angle += angleSize; 112 } 113 return points; 114 }, 115 _getPoint: function(angle, radiusX, radiusY) { 116 return new L.Point(this._point.x + this.options.position.x + radiusX * Math.cos(angle), this._point.y + this.options.position.y + radiusY * Math.sin(angle)); 117 } 118}); 119 120L.regularPolygonMarker = function(centerLatLng, options) { 121 return new L.RegularPolygonMarker(centerLatLng, options); 122}; 123 124L.SquareMarker = L.RegularPolygonMarker.extend({ 125 options: { 126 numberOfSides: 4, 127 stroke: true, 128 weight: 2, 129 color: "#fff", 130 rotation: 45, 131 radius: 8 132 } 133}); 134 135L.squareMarker = function(centerLatLng, options) { 136 return new L.SquareMarker(centerLatLng, options); 137};
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.