PageSourceSearch

https://villainville.fr/lib/leaflet-markers/leaflet.awesome-markers.js

js villainville.fr collected 2026-10-03 01:50:21 UTC 3,789 bytes, 125 lines download raw bytes

vendor: 3,789 bytes, lines 1-125
1/*
2  Leaflet.AwesomeMarkers, a plugin that adds colorful iconic markers for Leaflet, based on the Font Awesome icons
3  (c) 2012-2013, Lennard Voogdt
4
5  http://leafletjs.com
6  https://github.com/lvoogdt
7*/
8
9/*global L*/
10
11(function (window, document, undefined) {
12    "use strict";
13    /*
14     * Leaflet.AwesomeMarkers assumes that you have already included the Leaflet library.
15     */
16
17    L.AwesomeMarkers = {};
18
19    L.AwesomeMarkers.version = '2.0.1';
20
21    L.AwesomeMarkers.Icon = L.Icon.extend({
22        options: {
23            iconSize: [35, 45],
24            iconAnchor:   [17, 42],
25            popupAnchor: [1, -32],
26            shadowAnchor: [10, 12],
27            shadowSize: [36, 16],
28            className: 'awesome-marker',
29            prefix: 'glyphicon',
30            spinClass: 'fa-spin',
31            extraClasses: '',
32            icon: 'home',
33            markerColor: 'blue',
34            iconColor: 'white'
35        },
36
37        initialize: function (options) {
38            options = L.Util.setOptions(this, options);
39        },
40
41        createIcon: function () {
42            var div = document.createElement('div'),
43                options = this.options;
44
45            if (options.icon) {
46                div.innerHTML = this._createInner();
47            }
48
49            if (options.bgPos) {
50                div.style.backgroundPosition =
51                    (-options.bgPos.x) + 'px ' + (-options.bgPos.y) + 'px';
52            }
53
54            this._setIconStyles(div, 'icon-' + options.markerColor);
55            return div;
56        },
57
58        _createInner: function() {
59            var iconClass, iconSpinClass = "", iconColorClass = "", iconColorStyle = "", options = this.options;
60
61            if(options.icon.slice(0,options.prefix.length+1) === options.prefix + "-") {
62                iconClass = options.icon;
63            } else {
64                iconClass = options.prefix + "-" + options.icon;
65            }
66
67            if(options.spin && typeof options.spinClass === "string") {
68                iconSpinClass = options.spinClass;
69            }
70
71            if(options.iconColor) {
72                if(options.iconColor === 'white' || options.iconColor === 'black') {
73                    iconColorClass = "icon-" + options.iconColor;
74                } else {
75                    iconColorStyle = "style='color: " + options.iconColor + "' ";
76                }
77            }
78
79            return "<i " + iconColorStyle + "class='" + options.extraClasses + " " + options.prefix + " " + iconClass + " " + iconSpinClass + " " + iconColorClass + "'></i>";
80        },
81
82        _setIconStyles: function (img, name) {
83            var options = this.options,
84                size = L.point(options[name === 'shadow' ? 'shadowSize' : 'iconSize']),
85                anchor;
86
87            if (name === 'shadow') {
88                anchor = L.point(options.shadowAnchor || options.iconAnchor);
89            } else {
90                anchor = L.point(options.iconAnchor);
91            }
92
93            if (!anchor && size) {
94                anchor = size.divideBy(2, true);
95            }
96
97            img.className = 'awesome-marker-' + name + ' ' + options.className;
98
99            if (anchor) {
100                img.style.marginLeft = (-anchor.x) + 'px';
101                img.style.marginTop  = (-anchor.y) + 'px';
102            }
103
104            if (size) {
105                img.style.width  = size.x + 'px';
106                img.style.height = size.y + 'px';
107            }
108        },
109
110        createShadow: function () {
111            var div = document.createElement('div');
112
113            this._setIconStyles(div, 'shadow');
114            return div;
115      }
116    });
117        
118    L.AwesomeMarkers.icon = function (options) {
119        return new L.AwesomeMarkers.Icon(options);
120    };
121
122}(this, document));
123
124
125

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.