mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Prevent map error when no entities with location data
This commit is contained in:
parent
9aa7a2a162
commit
c58218f497
@ -105,8 +105,15 @@ Polymer({
|
|||||||
},
|
},
|
||||||
|
|
||||||
fitMap: function () {
|
fitMap: function () {
|
||||||
var bounds = new window.L.latLngBounds(
|
var bounds;
|
||||||
this._mapItems.map(function (item) { return item.getLatLng(); }));
|
|
||||||
|
if (this._mapItems.length === 0) {
|
||||||
|
bounds = new window.L.latLngBounds(
|
||||||
|
[window.L.latLng(this.locationGPS.latitude, this.locationGPS.longitude)])
|
||||||
|
} else {
|
||||||
|
bounds = new window.L.latLngBounds(
|
||||||
|
this._mapItems.map(function (item) { return item.getLatLng(); }));
|
||||||
|
}
|
||||||
|
|
||||||
this._map.fitBounds(bounds.pad(0.5));
|
this._map.fitBounds(bounds.pad(0.5));
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user