masajid390 / BeautifyMarker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot use brand FontAwesome icons with recent versions of FontAwesome

eric-g-97477 opened this issue · comments

commented

I have a codepen at https://codepen.io/ericg_off/pen/BarwMKL which demonstrates the issue. It is using version 5.13.0 of FontAwesome. If I move back to version 4.6.1 of FontAwesome, the codepen works.

If I try to set the prefix to 'fab', I end up with fab fab-google which does not work. I need to be able to set the class (fa, fab, etc.) separate from the prefix attached to the icons. This does not currently appear possible.

The HTML that is inserted into the page is:

<i class="fa fa-google" style="color:green;margin-top:3px; margin-left:0px;"></I>

If I use Chrome's editor tools and change that to:

<i class="fab fa-google" style="color:green;margin-top:3px; margin-left:0px;"></I>

It will work.

HTML

<div id="map"></div>

CSS

#map {
  height: 100vh;
}

#map >>> .my-icons {
  background-color: rgba(0, 255, 0, 0);
}

JS

var map = L.map("map", {
  center: [38, -77],
  zoom: 5
});

// Create a Tile Layer and add it to the map
var tiles = new L.tileLayer(
  "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
  {
    attribution:
      '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
    minZoom: 3,
    maxZoom: 8
  }
).addTo(map);

var fromIcon = L.BeautifyIcon.icon({
  icon: "leaf",
  iconShape: "circle",
  textColor: "green"
});

var toIcon = L.BeautifyIcon.icon({
  icon: "google",
  iconShape: "circle",
  textColor: "green"
});

const markerLayer = L.layerGroup().addTo(map);
const lineLayer = L.layerGroup().addTo(map);

const from = [38, -77];
const to = [38, -100];

const fromMarker = L.marker(from, {
  icon: fromIcon
}).addTo(lineLayer);

const toMarker = L.marker(to, {
  icon: toIcon
}).addTo(lineLayer);

const line = L.polyline([from, to], { color: "green", weight: 1 }).addTo(
  markerLayer
);

For the temporary fix, you can do something like

var toIcon = L.BeautifyIcon.icon({
  icon: " fab fa-google",
  iconShape: "circle",
  textColor: "green",
  prefix: ''
});

Codepen