From be1267e96abb6b3c23ecf2496ae135d8b736323c Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Thu, 29 May 2014 22:20:25 +0100 Subject: Check that the level exists before trying to remove it --- leaflet-indoor.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/leaflet-indoor.js b/leaflet-indoor.js index be73a6e..ee3fd52 100644 --- a/leaflet-indoor.js +++ b/leaflet-indoor.js @@ -71,7 +71,10 @@ L.Indoor = L.Class.extend({ } }, onRemove: function (map) { - this._map.removeLayer(this._layers[this._level]); + if (this._level in this._layers) { + this._map.removeLayer(this._layers[this._level]); + } + this._map = null; }, addData: function(data) { -- cgit v1.2.3