angular-google-maps
angular-google-maps copied to clipboard
TypeError: Cannot read property 'removeChild' of null
For anyone hitting this issue when clustering markers, it is a result of using third-party library of MarkerWithLabel
`MarkerLabel_.prototype.onRemove = function () { var i; this.labelDiv_.parentNode.removeChild(this.labelDiv_); this.eventDiv_.parentNode.removeChild(this.eventDiv_);
// Remove event listeners: for (i = 0; i < this.listeners_.length; i++) { google.maps.event.removeListener(this.listeners_[i]); } };`
needs to change this:
this.labelDiv_.parentNode.removeChild(this.labelDiv_);
to this:
if (this.labelDiv_.parentNode){ this.labelDiv_.parentNode.removeChild(this.labelDiv_); }
@nmccready any fix for that?
I am facing the same issue. @nmccready : If you can look into this issue and add check for all three lines before removing child and listener that will be helpful.
this is what i am looking for:
"MarkerLabel_.prototype.onRemove = function () { var i; this.labelDiv_.parentNode && this.labelDiv_.parentNode.removeChild(this.labelDiv_); this.eventDiv_.parentNode && this.eventDiv_.parentNode.removeChild(this.eventDiv_);
// Remove event listeners: if(this.listeners_) { for (i = 0; i < this.listeners_.length; i++) { google.maps.event.removeListener(this.listeners_[i]); } } };"
Came across this same issue. The newer version of MarkerWithLabel at https://github.com/googlemaps/v3-utility-library/tree/master/markerwithlabel fixes this issue.
I ended up just removing the MarkerWithLabel included in angular-google-maps and included the new version before this script is loaded
The state of this application is tough as it is severely outdated. I spent a decent amount of time trying to get it building so I could test out the problems. Anyway, I did not get far. I will make more attempts later but please follow @danthul suggestions.
@danthul how did you remove the MarkerWithLabel ? did you just remove MarkerWithLabel locally from angular-google-maps.js file or forked the library and fixed the issue there?
I just removed it from the file and took it local until this gets fixed.