mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +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) {
|
||||
return;
|
||||
}
|
||||
let autoFitRequired = false;
|
||||
const oldHass = changedProps.get("hass") as HomeAssistant | undefined;
|
||||
|
||||
if (changedProps.has("_loaded") || changedProps.has("entities")) {
|
||||
this._drawEntities();
|
||||
autoFitRequired = true;
|
||||
} else if (this._loaded && oldHass && this.entities) {
|
||||
// Check if any state has changed
|
||||
for (const entity of this.entities) {
|
||||
@ -119,6 +121,7 @@ export class HaMap extends ReactiveElement {
|
||||
this.hass!.states[getEntityId(entity)]
|
||||
) {
|
||||
this._drawEntities();
|
||||
autoFitRequired = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -130,13 +133,10 @@ export class HaMap extends ReactiveElement {
|
||||
|
||||
if (changedProps.has("_loaded") || changedProps.has("layers")) {
|
||||
this._drawLayers(changedProps.get("layers") as Layer[] | undefined);
|
||||
autoFitRequired = true;
|
||||
}
|
||||
|
||||
if (
|
||||
changedProps.has("_loaded") ||
|
||||
((changedProps.has("entities") || changedProps.has("layers")) &&
|
||||
this.autoFit)
|
||||
) {
|
||||
if (this.autoFit && autoFitRequired) {
|
||||
this.fitMap();
|
||||
}
|
||||
|
||||
|
@ -216,13 +216,12 @@ class HuiMapCard extends LitElement implements LovelaceCard {
|
||||
protected willUpdate(changedProps: PropertyValues): void {
|
||||
super.willUpdate(changedProps);
|
||||
if (
|
||||
(changedProps.has("hass") &&
|
||||
this._config?.geo_location_sources &&
|
||||
!deepEqual(
|
||||
this._getSourceEntities(changedProps.get("hass")?.states),
|
||||
this._getSourceEntities(this.hass.states)
|
||||
)) ||
|
||||
(this._config?.entities && hasConfigOrEntitiesChanged(this, changedProps))
|
||||
changedProps.has("hass") &&
|
||||
this._config?.geo_location_sources &&
|
||||
!deepEqual(
|
||||
this._getSourceEntities(changedProps.get("hass")?.states),
|
||||
this._getSourceEntities(this.hass.states)
|
||||
)
|
||||
) {
|
||||
this._mapEntities = this._getMapEntities();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user