Skip to content
This repository has been archived by the owner on Nov 30, 2018. It is now read-only.

TypeError: Cannot read property 'removeChild' of null #2038

Open
lironbar opened this issue Aug 21, 2018 · 5 comments
Open

TypeError: Cannot read property 'removeChild' of null #2038

lironbar opened this issue Aug 21, 2018 · 5 comments

Comments

@lironbar
Copy link

lironbar commented Aug 21, 2018

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?

@neeraj-gupta
Copy link

neeraj-gupta commented Aug 21, 2018

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

@danthul
Copy link

danthul commented Aug 27, 2018

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

@nmccready
Copy link
Contributor

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.

@lironbar
Copy link
Author

lironbar commented Sep 5, 2018

@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?

@danthul
Copy link

danthul commented Sep 6, 2018

I just removed it from the file and took it local until this gets fixed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants