/*! * leaflet-extra-markers * Custom Markers for Leaflet JS based on Awesome Markers * Leaflet ExtraMarkers * https://github.com/coryasilva/Leaflet.ExtraMarkers/ * @author coryasilva * @version 1.2.1 */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (factory((global.leaflet = global.leaflet || {}, global.leaflet['extra-markers'] = {}))); }(this, (function (exports) { 'use strict'; var ExtraMarkers = L.ExtraMarkers = {}; ExtraMarkers.version = L.ExtraMarkers.version = "1.2.1"; ExtraMarkers.Icon = L.ExtraMarkers.Icon = L.Icon.extend({ options: { iconSize: [ 35, 45 ], iconAnchor: [ 17, 42 ], popupAnchor: [ 1, -32 ], shadowAnchor: [ 10, 12 ], shadowSize: [ 36, 16 ], className: "", prefix: "", extraClasses: "", shape: "circle", icon: "", innerHTML: "", markerColor: "red", svgBorderColor: "#fff", svgOpacity: 1, iconColor: "#fff", iconRotate: 0, number: "", svg: false }, initialize: function(options) { options = L.Util.setOptions(this, options); }, createIcon: function() { var div = document.createElement("div"), options = this.options; if (options.icon) { div.innerHTML = this._createInner(); } if (options.innerHTML) { div.innerHTML = options.innerHTML; } if (options.bgPos) { div.style.backgroundPosition = -options.bgPos.x + "px " + -options.bgPos.y + "px"; } if (!options.svg) { this._setIconStyles(div, options.shape + "-" + options.markerColor); } else { this._setIconStyles(div, "svg"); } return div; }, _getColorHex: function (color) { var colorMap = { red: "#a23337", "orange-dark": "#d73e29", orange: "#ef9227", yellow: "#f5bb39", "blue-dark": "#276273", cyan: "#32a9dd", purple: "#440444", violet: "#90278d", pink: "#c057a0", green: "#006838", white: "#e8e8e8", black: "#211c1d" }; return colorMap[color] || color; }, _createSvg: function (shape, markerColor) { var svgMap = { circle: '', square: '', star: '', penta: '' }; return svgMap[shape]; }, _createInner: function() { var iconStyle = "", iconNumber = "", iconClass = "", result = "", options = this.options; if (options.iconColor) { iconStyle = "color: " + options.iconColor + ";"; } if (options.iconRotate !== 0) { iconStyle += "-webkit-transform: rotate(" + options.iconRotate + "deg);"; iconStyle += "-moz-transform: rotate(" + options.iconRotate + "deg);"; iconStyle += "-o-transform: rotate(" + options.iconRotate + "deg);"; iconStyle += "-ms-transform: rotate(" + options.iconRotate + "deg);"; iconStyle += "transform: rotate(" + options.iconRotate + "deg);"; } if (options.number) { iconNumber = 'number="' + options.number + '" '; } if (options.extraClasses.length) { iconClass += options.extraClasses + " "; } if (options.prefix.length) { iconClass += options.prefix + " "; } if (options.icon.length) { iconClass += options.icon + " "; } if (options.svg) { result += this._createSvg(options.shape, this._getColorHex(options.markerColor)); } result += ''; return result; }, _setIconStyles: function(img, name) { var options = this.options, size = L.point(options[name === "shadow" ? "shadowSize" : "iconSize"]), anchor, leafletName; if (name === "shadow") { anchor = L.point(options.shadowAnchor || options.iconAnchor); leafletName = "shadow"; } else { anchor = L.point(options.iconAnchor); leafletName = "icon"; } if (!anchor && size) { anchor = size.divideBy(2, true); } img.className = "leaflet-marker-" + leafletName + " extra-marker extra-marker-" + name + " " + options.className; if (anchor) { img.style.marginLeft = -anchor.x + "px"; img.style.marginTop = -anchor.y + "px"; } if (size) { img.style.width = size.x + "px"; img.style.height = size.y + "px"; } }, createShadow: function() { var div = document.createElement("div"); this._setIconStyles(div, "shadow"); return div; } }); ExtraMarkers.icon = L.ExtraMarkers.icon = function(options) { return new L.ExtraMarkers.Icon(options); }; exports.ExtraMarkers = ExtraMarkers; Object.defineProperty(exports, '__esModule', { value: true }); }))); //# sourceMappingURL=leaflet.extra-markers.js.map