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]); + } } };