1L.Icon.FontAwesome = L.Icon.extend({ 2 markerContainer: null, 3 markerSvg: null, 4 iconContainer: null, 5 icon: null, 6 7 options: { 8 popupAnchor: [0, -50] 9 }, 10 11 /*------------------------------- LEAFLET -------------------------------*/ 12 13 createIcon: function () { 14 const div = document.createElement("div"); 15 const options = this.options; 16 17 if (options.iconClasses) { 18 div.appendChild(this._createIcon()); 19 } 20 21 return div; 22 }, 23 24 /*------------------------------- PUBLIC -------------------------------*/ 25 26 setStyle: function (style) { 27 Object.assign(this.options, style); 28 const path = this.markerSvg.getElementsByTagName("path")[0]; 29 const icon = this.markerContainer.getElementsByTagName("i")[0]; 30 if (style.hasOwnProperty("markerColor")) 31 path.setAttribute("fill", style.markerColor); 32 if (style.hasOwnProperty("markerFillOpacity")) 33 path.setAttribute("fill-opacity", style.markerFillOpacity); 34 if (style.hasOwnProperty("markerStrokeColor")) 35 path.setAttribute("stroke", style.markerStrokeColor); 36 if (style.hasOwnProperty("markerStrokeWidth")) 37 path.setAttribute("stroke-width", style.markerStrokeWidth); 38 if (style.hasOwnProperty("iconXOffset")) 39 icon.style.marginLeft = `${style.iconXOffset}px`; 40 if (style.hasOwnProperty("iconYOffset")) 41 icon.style.marginTop = `${style.iconYOffset}px`; 42 if (style.hasOwnProperty("iconColor")) 43 icon.style.color = style.iconColor; 44 if (style.hasOwnProperty("iconSize")) 45 icon.style.fontSize = `${style.iconSize}px`; 46 }, 47 48 /*------------------------------- PRIVATE -------------------------------*/ 49 50 _createIcon: function () { 51 const options = this.options; 52 53 // container div 54 this.markerContainer = L.DomUtil.create("div", "leaflet-fa-markers"); 55 56 // icon container div 57 this.iconContainer = L.DomUtil.create("div", 'icon-container'); 58 59 // feature icon 60 this.icon = L.DomUtil.create( 61 "i", 62 options.iconClasses + " feature-icon" 63 ); 64 this.icon.style.color = options.iconColor; 65 this.icon.style.textAlign = "center"; 66 67 // XY position adjustments 68 if (options.iconYOffset && options.iconYOffset != 0) 69 this.icon.style.marginTop = options.iconYOffset + "px"; 70 if (options.iconXOffset && options.iconXOffset != 0) 71 this.icon.style.marginLeft = options.iconXOffset + "px"; 72 73 // set icon size 74 if (options.iconSize && options.iconSize !== 0) 75 this.icon.style.fontSize = `${options.iconSize}px`; 76 77 // marker styles 78 const fillOpacity = options.markerFillOpacity || 1; 79 const strokeColor = options.markerStrokeColor || options.markerColor; 80 const strokeWidth = options.markerStrokeWidth || 1; 81 82 // marker icon L.DomUtil doesn't seem to like svg, just append out html directly 83 this.markerSvg = document.createElement("div"); 84 this.markerSvg.className = "marker-icon-svg"; 85 this.markerSvg.innerHTML = 86 "<svg " + 87 'width="32px" ' + 88 'height="52px" ' + 89 'viewBox="0 0 32 52" ' + 90 'version="1.1" ' + 91 'xmlns="http://www.w3.org/2000/svg" ' + 92 'xmlns:xlink="http://www.w3.org/1999/xlink">' + 93 `<path d="${options.markerPath}"` + 94 `fill-opacity="${fillOpacity}"` + 95 `fill="${options.markerColor}"` + 96 `stroke="${strokeColor}"` + 97 `stroke-width="${strokeWidth}"` + 98 "></path></svg>"; 99 100 this.iconContainer.appendChild(this.icon) 101 this.markerContainer.appendChild(this.markerSvg); 102 this.markerContainer.appendChild(this.iconContainer); 103 return this.markerContainer; 104 } 105}); 106 107L.icon.fontAwesome = function (options) { 108 return new L.Icon.FontAwesome(options); 109}; 110 111L.Icon.FontAwesome.prototype.options.markerPath = 112 "M16,1 C7.7146,1 1,7.65636364 1,15.8648485 C1,24.0760606 16,51 16,51 C16,51 31,24.0760606 31,15.8648485 C31,7.65636364 24.2815,1 16,1 L16,1 Z";
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.