Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions src/panels/lovelace/cards/hui-map-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,13 +325,25 @@ class HuiMapCard extends LitElement implements LovelaceCard {
continue;
}

// create icon
let iconHTML = "";
if (icon) {
const el = document.createElement("ha-icon");
el.setAttribute("icon", icon);
iconHTML = el.outerHTML;
} else {
const el = document.createElement("span");
el.innerHTML = title;
iconHTML = el.outerHTML;
}

// create marker with the icon
mapItems.push(
Leaflet.marker([latitude, longitude], {
icon: Leaflet.divIcon({
html: icon ? `<ha-icon icon="${icon}"></ha-icon>` : title,
html: iconHTML,
iconSize: [24, 24],
className: "",
className: this._config!.dark_mode === true ? "dark" : "light",
}),
interactive: false,
title,
Expand Down Expand Up @@ -455,6 +467,14 @@ class HuiMapCard extends LitElement implements LovelaceCard {
:host([ispanel]) #root {
height: 100%;
}

.dark {
color: #ffffff;
}

.light {
color: #000000;
}
`;
}
}
Expand Down
12 changes: 9 additions & 3 deletions src/panels/map/ha-panel-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ class HaPanelMap extends LocalizeMixin(PolymerElement) {
width: 100%;
z-index: 0;
}

.light {
color: #000000;
}
</style>

<app-toolbar>
Expand Down Expand Up @@ -120,16 +124,18 @@ class HaPanelMap extends LocalizeMixin(PolymerElement) {
el.setAttribute("icon", entity.attributes.icon);
iconHTML = el.outerHTML;
} else {
iconHTML = title;
const el = document.createElement("span");
el.innerHTML = title;
iconHTML = el.outerHTML;
}

icon = this.Leaflet.divIcon({
html: iconHTML,
iconSize: [24, 24],
className: "",
className: "light",
});

// create market with the icon
// create marker with the icon
mapItems.push(
this.Leaflet.marker(
[entity.attributes.latitude, entity.attributes.longitude],
Expand Down