Files
librenms/dist/leaflet.awesome-markers.min.js
T
2013-03-16 01:08:56 +01:00

8 lines
1.3 KiB
JavaScript

/*
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
*/
(function(e,t,n){L.IconMarker={};L.IconMarker.version="0.0.5-dev";L.IconMarker.Icon=L.Icon.extend({options:{iconSize:[35,45],iconAnchor:[17,42],popupAnchor:[1,-32],shadowAnchor:[10,12],icon:"icon-font",shadowSize:[36,16],className:"icon-marker",color:"blue"},initialize:function(e){e=L.setOptions(this,e)},createIcon:function(){var e=t.createElement("div"),n=this.options;if(n.icon){e.innerHTML=this._createInner()}if(n.bgPos){e.style.backgroundPosition=-n.bgPos.x+"px "+ -n.bgPos.y+"px"}this._setIconStyles(e,"icon-"+n.color);return e},_createInner:function(){return"<i class='"+this.options.icon+"'></i>"},_setIconStyles:function(e,t){var n=this.options,r=L.point(n[t+"Size"]),i;if(t==="shadow"){i=L.point(n.shadowAnchor||n.iconAnchor)}else{i=L.point(n.iconAnchor)}if(!i&&r){i=r.divideBy(2,true)}e.className="icon-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"),n=this.options;this._setIconStyles(e,"shadow");return e}});L.IconMarker.icon=function(e){return new L.IconMarkers.Icon(e)}})(this,document)