Skip to content

Commit 394c9ac

Browse files
committed
Fix font awesome markers
1 parent 861d8c2 commit 394c9ac

File tree

3 files changed

+36
-35
lines changed

3 files changed

+36
-35
lines changed

index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
<script src="https://cdn.jsdelivr.net/npm/[email protected]/papaparse.min.js"></script>
2424

2525
<!-- Font Awesome -->
26-
<script src="https://use.fontawesome.com/77cd9dd4f5.js"></script>
26+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/all.min.css">
27+
<script src="https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/js/fontawesome.min.js"></script>
2728

2829
<!-- leaflet-providers-->
2930
<script src="https://unpkg.com/[email protected]/leaflet-providers.js"></script>

scripts/Leaflet.awesome-markers/dist/leaflet.awesome-markers.js

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737
var svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
3838
var path = document.createElementNS('http://www.w3.org/2000/svg', "path");
3939
var backgroundCircle = document.createElementNS('http://www.w3.org/2000/svg', "circle");
40-
var icongroup = document.createElementNS('http://www.w3.org/2000/svg', "g");
41-
var icon = document.createElementNS('http://www.w3.org/2000/svg', "text");
40+
4241

4342
svg.setAttribute('width', '31');
4443
svg.setAttribute('height', '42');
@@ -55,37 +54,38 @@
5554
path.setAttribute('stroke', 'white');
5655
path.setAttribute('style', 'fill:' + options.markerColor)
5756

58-
icon.textContent = options.icon;
59-
icon.setAttribute('x', '7');
60-
icon.setAttribute('y', '23');
61-
icon.setAttribute('class', 'material-icons');
62-
icon.setAttribute('fill', options.iconColor);
63-
icon.setAttribute('font-family', 'Material Icons');
64-
65-
svg.appendChild(path);
66-
svg.appendChild(backgroundCircle);
67-
icongroup.appendChild(icon);
68-
svg.appendChild(icongroup);
57+
if (options.icon && options.icon.indexOf('fa-') === 0) {
58+
var icongroup = document.createElementNS('http://www.w3.org/2000/svg', "foreignObject");
59+
var icon = document.createElement('i');
6960

70-
return svg;
71-
},
61+
icongroup.setAttribute('height', '42');
62+
icongroup.setAttribute('width', '31');
7263

73-
_createInner: function() {
74-
var iconClass, iconSpinClass = "", iconColorClass = "", iconColorStyle = "", options = this.options;
64+
icon.setAttribute('class', 'fas ' + options.icon);
65+
icon.style.color = options.iconColor;
7566

76-
if (options.spin && typeof options.spinClass === "string") {
77-
iconSpinClass = options.spinClass;
67+
svg.appendChild(path);
68+
svg.appendChild(backgroundCircle);
69+
icongroup.appendChild(icon);
70+
svg.appendChild(icongroup);
71+
72+
} else {
73+
var icongroup = document.createElementNS('http://www.w3.org/2000/svg', "g");
74+
var icon = document.createElementNS('http://www.w3.org/2000/svg', "text");
75+
icon.textContent = options.icon;
76+
icon.setAttribute('x', '7');
77+
icon.setAttribute('y', '23');
78+
icon.setAttribute('class', 'material-icons');
79+
icon.setAttribute('fill', options.iconColor);
80+
icon.setAttribute('font-family', 'Material Icons');
81+
82+
svg.appendChild(path);
83+
svg.appendChild(backgroundCircle);
84+
icongroup.appendChild(icon);
85+
svg.appendChild(icongroup);
7886
}
7987

80-
if (options.iconColor) {
81-
if (options.iconColor === 'white' || options.iconColor === 'black') {
82-
iconColorClass = "icon-" + options.iconColor;
83-
} else {
84-
iconColorStyle = "style='color: " + options.iconColor + "' ";
85-
}
86-
}
87-
//return "<i " + iconColorStyle + "class='" + options.extraClasses + " " + options.prefix + " " + iconClass + " " + iconSpinClass + " " + iconColorClass + "'></i>"
88-
return options.extraClasses + " " + iconClass + " " + iconSpinClass + " " + iconColorClass;
88+
return svg;
8989
},
9090

9191
_setIconStyles: function (img, name) {

scripts/map.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ $(window).on('load', function() {
177177

178178
$('#points-legend').prepend('<h6 class="pointer">' + getSetting('_pointsLegendTitle') + '</h6>');
179179
if (getSetting('_pointsLegendIcon') != '') {
180-
$('#points-legend h6').prepend('<span class="legend-icon"><i class="fa '
180+
$('#points-legend h6').prepend('<span class="legend-icon"><i class="fas '
181181
+ getSetting('_pointsLegendIcon') + '"></i></span>');
182182
}
183183

@@ -686,7 +686,7 @@ $(window).on('load', function() {
686686
$('#points-legend label span').each(function(i) {
687687
var legendIcon = (markerColors[i].indexOf('.') > 0)
688688
? '<img src="' + markerColors[i] + '" class="markers-legend-icon">'
689-
: '&nbsp;<i class="fa fa-map-marker" style="color: '
689+
: '&nbsp;<i class="fas fa-map-marker" style="color: '
690690
+ markerColors[i]
691691
+ '"></i>';
692692
$(this).prepend(legendIcon);
@@ -697,13 +697,13 @@ $(window).on('load', function() {
697697

698698
function showMap() {
699699
if (completePoints && completePolylines && completePolygons) {
700-
$('.ladder h6').append('<span class="legend-arrow"><i class="fa fa-chevron-down"></i></span>');
700+
$('.ladder h6').append('<span class="legend-arrow"><i class="fas fa-chevron-down"></i></span>');
701701
$('.ladder h6').addClass('minimize');
702702

703703
for (i in allPolygonLegends) {
704704
if (getPolygonSetting(i, '_polygonsLegendIcon') != '') {
705705
$('.polygons-legend' + i + ' h6').prepend(
706-
'<span class="legend-icon"><i class="fa ' + getPolygonSetting(i, '_polygonsLegendIcon') + '"></i></span>');
706+
'<span class="legend-icon"><i class="fas ' + getPolygonSetting(i, '_polygonsLegendIcon') + '"></i></span>');
707707
}
708708
}
709709

@@ -834,7 +834,7 @@ $(window).on('load', function() {
834834
if (getSetting('_polylinesLegendTitle') != '') {
835835
$('#polylines-legend').prepend('<h6 class="pointer">' + getSetting('_polylinesLegendTitle') + '</h6>');
836836
if (getSetting('_polylinesLegendIcon') != '') {
837-
$('#polylines-legend h6').prepend('<span class="legend-icon"><i class="fa '
837+
$('#polylines-legend h6').prepend('<span class="legend-icon"><i class="fas '
838838
+ getSetting('_polylinesLegendIcon') + '"></i></span>');
839839
}
840840

@@ -864,7 +864,7 @@ $(window).on('load', function() {
864864
// This is a pop-up for mobile device
865865
if (window.matchMedia("only screen and (max-width: 760px)").matches) {
866866
$('body').append('<div id="mobile-intro-popup"><p>' + info +
867-
'</p><div id="mobile-intro-popup-close"><i class="fa fa-times"></i></div></div>');
867+
'</p><div id="mobile-intro-popup-close"><i class="fas fa-times"></i></div></div>');
868868

869869
$('#mobile-intro-popup-close').click(function() {
870870
$("#mobile-intro-popup").hide();

0 commit comments

Comments
 (0)