From 363099dcc7ecc4a40bdf58150d2825406f2b990d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ste=CC=81phane=20Este-Gracias?= Date: Wed, 4 Apr 2018 11:47:34 +0200 Subject: [PATCH] Fix https://github.com/googlemaps/v3-utility-library/issues/393 MarkerWithLabel: Cannot read property 'removeChild' of null --- lib/js/markerwithlabel.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/js/markerwithlabel.js b/lib/js/markerwithlabel.js index c46df52..48c7ccb 100644 --- a/lib/js/markerwithlabel.js +++ b/lib/js/markerwithlabel.js @@ -306,11 +306,15 @@ MarkerLabel_.prototype.onAdd = function () { */ MarkerLabel_.prototype.onRemove = function () { var i; - this.labelDiv_.parentNode.removeChild(this.labelDiv_); + if (this.labelDiv_.parentNode) { + this.labelDiv_.parentNode.removeChild(this.labelDiv_); + } // Remove event listeners: - for (i = 0; i < this.listeners_.length; i++) { - google.maps.event.removeListener(this.listeners_[i]); + if (this.listeners_) { + for (i = 0; i < this.listeners_.length; i++) { + google.maps.event.removeListener(this.listeners_[i]); + } } };