mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Fix map auto-fit (#18801)
This commit is contained in:
parent
2acd1ff5e8
commit
44157a5df3
@ -107,10 +107,12 @@ export class HaMap extends ReactiveElement {
|
|||||||
if (!this._loaded) {
|
if (!this._loaded) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let autoFitRequired = false;
|
||||||
const oldHass = changedProps.get("hass") as HomeAssistant | undefined;
|
const oldHass = changedProps.get("hass") as HomeAssistant | undefined;
|
||||||
|
|
||||||
if (changedProps.has("_loaded") || changedProps.has("entities")) {
|
if (changedProps.has("_loaded") || changedProps.has("entities")) {
|
||||||
this._drawEntities();
|
this._drawEntities();
|
||||||
|
autoFitRequired = true;
|
||||||
} else if (this._loaded && oldHass && this.entities) {
|
} else if (this._loaded && oldHass && this.entities) {
|
||||||
// Check if any state has changed
|
// Check if any state has changed
|
||||||
for (const entity of this.entities) {
|
for (const entity of this.entities) {
|
||||||
@ -119,6 +121,7 @@ export class HaMap extends ReactiveElement {
|
|||||||
this.hass!.states[getEntityId(entity)]
|
this.hass!.states[getEntityId(entity)]
|
||||||
) {
|
) {
|
||||||
this._drawEntities();
|
this._drawEntities();
|
||||||
|
autoFitRequired = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -130,13 +133,10 @@ export class HaMap extends ReactiveElement {
|
|||||||
|
|
||||||
if (changedProps.has("_loaded") || changedProps.has("layers")) {
|
if (changedProps.has("_loaded") || changedProps.has("layers")) {
|
||||||
this._drawLayers(changedProps.get("layers") as Layer[] | undefined);
|
this._drawLayers(changedProps.get("layers") as Layer[] | undefined);
|
||||||
|
autoFitRequired = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (this.autoFit && autoFitRequired) {
|
||||||
changedProps.has("_loaded") ||
|
|
||||||
((changedProps.has("entities") || changedProps.has("layers")) &&
|
|
||||||
this.autoFit)
|
|
||||||
) {
|
|
||||||
this.fitMap();
|
this.fitMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,13 +216,12 @@ class HuiMapCard extends LitElement implements LovelaceCard {
|
|||||||
protected willUpdate(changedProps: PropertyValues): void {
|
protected willUpdate(changedProps: PropertyValues): void {
|
||||||
super.willUpdate(changedProps);
|
super.willUpdate(changedProps);
|
||||||
if (
|
if (
|
||||||
(changedProps.has("hass") &&
|
changedProps.has("hass") &&
|
||||||
this._config?.geo_location_sources &&
|
this._config?.geo_location_sources &&
|
||||||
!deepEqual(
|
!deepEqual(
|
||||||
this._getSourceEntities(changedProps.get("hass")?.states),
|
this._getSourceEntities(changedProps.get("hass")?.states),
|
||||||
this._getSourceEntities(this.hass.states)
|
this._getSourceEntities(this.hass.states)
|
||||||
)) ||
|
)
|
||||||
(this._config?.entities && hasConfigOrEntitiesChanged(this, changedProps))
|
|
||||||
) {
|
) {
|
||||||
this._mapEntities = this._getMapEntities();
|
this._mapEntities = this._getMapEntities();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user