From c58218f497bd0304b24c42b789ca5b5b7c478ab9 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 20 Jan 2017 22:46:31 -0800 Subject: [PATCH] Prevent map error when no entities with location data --- panels/map/ha-panel-map.html | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/panels/map/ha-panel-map.html b/panels/map/ha-panel-map.html index 399f7de59d..caa85b769d 100644 --- a/panels/map/ha-panel-map.html +++ b/panels/map/ha-panel-map.html @@ -105,8 +105,15 @@ Polymer({ }, fitMap: function () { - var bounds = new window.L.latLngBounds( - this._mapItems.map(function (item) { return item.getLatLng(); })); + var bounds; + + 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)); },