From 1232d91c9b4bcb66e11ce9c5943a49d00568c51c Mon Sep 17 00:00:00 2001 From: "K.K. POON" Date: Fri, 28 Mar 2014 14:47:29 +0800 Subject: [PATCH 1/2] add text option for marker --- dist/leaflet.awesome-markers.js | 17 ++++++++++++++--- dist/leaflet.awesome-markers.min.js | 8 +------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/dist/leaflet.awesome-markers.js b/dist/leaflet.awesome-markers.js index 7505b6f..d292b52 100644 --- a/dist/leaflet.awesome-markers.js +++ b/dist/leaflet.awesome-markers.js @@ -31,7 +31,8 @@ extraClasses: '', icon: 'home', markerColor: 'blue', - iconColor: 'white' + iconColor: 'white', + font: 'monospace' }, initialize: function (options) { @@ -72,11 +73,21 @@ if(options.iconColor === 'white' || options.iconColor === 'black') { iconColorClass = "icon-" + options.iconColor; } else { - iconColorStyle = "style='color: " + options.iconColor + "' "; + iconColorStyle = "color: " + options.iconColor; } } + if(options.font && options.text) { + if (iconColorStyle) { + iconColorStyle += "; "; + } + iconColorStyle += "font-family: " + options.font; + } + + if (options.text) { + return "" + options.text + ""; + } - return ""; + return ""; }, _setIconStyles: function (img, name) { diff --git a/dist/leaflet.awesome-markers.min.js b/dist/leaflet.awesome-markers.min.js index 376e57e..bdb2b11 100644 --- a/dist/leaflet.awesome-markers.min.js +++ b/dist/leaflet.awesome-markers.min.js @@ -1,7 +1 @@ -/* - Leaflet.AwesomeMarkers, a plugin that adds colorful iconic markers for Leaflet, based on the Font Awesome icons - (c) 2012-2013, Lennard Voogdt - - http://leafletjs.com - https://github.com/lvoogdt -*//*global L*/(function(e,t,n){"use strict";L.AwesomeMarkers={};L.AwesomeMarkers.version="2.0.1";L.AwesomeMarkers.Icon=L.Icon.extend({options:{iconSize:[35,45],iconAnchor:[17,42],popupAnchor:[1,-32],shadowAnchor:[10,12],shadowSize:[36,16],className:"awesome-marker",prefix:"glyphicon",spinClass:"fa-spin",icon:"home",markerColor:"blue",iconColor:"white"},initialize:function(e){e=L.Util.setOptions(this,e)},createIcon:function(){var e=t.createElement("div"),n=this.options;n.icon&&(e.innerHTML=this._createInner());n.bgPos&&(e.style.backgroundPosition=-n.bgPos.x+"px "+ -n.bgPos.y+"px");this._setIconStyles(e,"icon-"+n.markerColor);return e},_createInner:function(){var e,t="",n="",r="",i=this.options;i.icon.slice(0,i.prefix.length+1)===i.prefix+"-"?e=i.icon:e=i.prefix+"-"+i.icon;i.spin&&typeof i.spinClass=="string"&&(t=i.spinClass);i.iconColor&&(i.iconColor==="white"||i.iconColor==="black"?n="icon-"+i.iconColor:r="style='color: "+i.iconColor+"' ");return""},_setIconStyles:function(e,t){var n=this.options,r=L.point(n[t==="shadow"?"shadowSize":"iconSize"]),i;t==="shadow"?i=L.point(n.shadowAnchor||n.iconAnchor):i=L.point(n.iconAnchor);!i&&r&&(i=r.divideBy(2,!0));e.className="awesome-marker-"+t+" "+n.className;if(i){e.style.marginLeft=-i.x+"px";e.style.marginTop=-i.y+"px"}if(r){e.style.width=r.x+"px";e.style.height=r.y+"px"}},createShadow:function(){var e=t.createElement("div");this._setIconStyles(e,"shadow");return e}});L.AwesomeMarkers.icon=function(e){return new L.AwesomeMarkers.Icon(e)}})(this,document); +!function(o,e){"use strict";L.AwesomeMarkers={},L.AwesomeMarkers.version="2.0.1",L.AwesomeMarkers.Icon=L.Icon.extend({options:{iconSize:[35,45],iconAnchor:[17,42],popupAnchor:[1,-32],shadowAnchor:[10,12],shadowSize:[36,16],className:"awesome-marker",prefix:"glyphicon",spinClass:"fa-spin",extraClasses:"",icon:"home",markerColor:"blue",iconColor:"white",font:"monospace"},initialize:function(o){o=L.Util.setOptions(this,o)},createIcon:function(){var o=e.createElement("div"),n=this.options;return n.icon&&(o.innerHTML=this._createInner()),n.bgPos&&(o.style.backgroundPosition=-n.bgPos.x+"px "+-n.bgPos.y+"px"),this._setIconStyles(o,"icon-"+n.markerColor),o},_createInner:function(){var o,e="",n="",s="",i=this.options;return o=i.icon.slice(0,i.prefix.length+1)===i.prefix+"-"?i.icon:i.prefix+"-"+i.icon,i.spin&&"string"==typeof i.spinClass&&(e=i.spinClass),i.iconColor&&("white"===i.iconColor||"black"===i.iconColor?n="icon-"+i.iconColor:s="color: "+i.iconColor),i.font&&i.text&&(s&&(s+="; "),s+="font-family: "+i.font),i.text?""+i.text+"":""},_setIconStyles:function(o,e){var n,s=this.options,i=L.point(s["shadow"===e?"shadowSize":"iconSize"]);n=L.point("shadow"===e?s.shadowAnchor||s.iconAnchor:s.iconAnchor),!n&&i&&(n=i.divideBy(2,!0)),o.className="awesome-marker-"+e+" "+s.className,n&&(o.style.marginLeft=-n.x+"px",o.style.marginTop=-n.y+"px"),i&&(o.style.width=i.x+"px",o.style.height=i.y+"px")},createShadow:function(){var o=e.createElement("div");return this._setIconStyles(o,"shadow"),o}}),L.AwesomeMarkers.icon=function(o){return new L.AwesomeMarkers.Icon(o)}}(this,document); \ No newline at end of file From f27342845dcc4bd65db01263577d91e3fae57924 Mon Sep 17 00:00:00 2001 From: Matt Barnes Date: Thu, 19 Mar 2015 09:58:14 +1300 Subject: [PATCH 2/2] Allow the prefix config option to be falsy. --- dist/leaflet.awesome-markers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/leaflet.awesome-markers.js b/dist/leaflet.awesome-markers.js index 7505b6f..36887d1 100644 --- a/dist/leaflet.awesome-markers.js +++ b/dist/leaflet.awesome-markers.js @@ -58,7 +58,7 @@ _createInner: function() { var iconClass, iconSpinClass = "", iconColorClass = "", iconColorStyle = "", options = this.options; - if(options.icon.slice(0,options.prefix.length+1) === options.prefix + "-") { + if(!options.prefix || (options.icon.slice(0,options.prefix.length+1) === options.prefix + "-")) { iconClass = options.icon; } else { iconClass = options.prefix + "-" + options.icon; @@ -76,7 +76,7 @@ } } - return ""; + return ""; }, _setIconStyles: function (img, name) {