Use autofit when we detect location

This commit is contained in:
Ludeeus 2021-10-29 07:10:10 +00:00
parent 4624c3d75b
commit faf8e49c12

View File

@ -2,13 +2,16 @@ import "@material/mwc-button/mwc-button";
import "@polymer/paper-input/paper-input"; import "@polymer/paper-input/paper-input";
import type { PaperInputElement } from "@polymer/paper-input/paper-input"; import type { PaperInputElement } from "@polymer/paper-input/paper-input";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state, query } from "lit/decorators";
import memoizeOne from "memoize-one"; import memoizeOne from "memoize-one";
import { fireEvent } from "../common/dom/fire_event"; import { fireEvent } from "../common/dom/fire_event";
import type { LocalizeFunc } from "../common/translations/localize"; import type { LocalizeFunc } from "../common/translations/localize";
import { createCurrencyListEl } from "../components/currency-datalist"; import { createCurrencyListEl } from "../components/currency-datalist";
import "../components/map/ha-locations-editor"; import "../components/map/ha-locations-editor";
import type { MarkerLocation } from "../components/map/ha-locations-editor"; import type {
HaLocationsEditor,
MarkerLocation,
} from "../components/map/ha-locations-editor";
import { createTimezoneListEl } from "../components/timezone-datalist"; import { createTimezoneListEl } from "../components/timezone-datalist";
import { import {
ConfigUpdateValues, ConfigUpdateValues,
@ -46,6 +49,8 @@ class OnboardingCoreConfig extends LitElement {
@state() private _timeZone?: string; @state() private _timeZone?: string;
@query("ha-locations-editor", true) private map!: HaLocationsEditor;
protected render(): TemplateResult { protected render(): TemplateResult {
return html` return html`
<p> <p>
@ -305,6 +310,7 @@ class OnboardingCoreConfig extends LitElement {
if (values.latitude && values.longitude) { if (values.latitude && values.longitude) {
this._location = [Number(values.latitude), Number(values.longitude)]; this._location = [Number(values.latitude), Number(values.longitude)];
this.map.autoFit = true;
} }
if (values.elevation) { if (values.elevation) {
this._elevation = String(values.elevation); this._elevation = String(values.elevation);