angular-google-maps icon indicating copy to clipboard operation
angular-google-maps copied to clipboard

TypeError: Cannot read property 'removeChild' of null

Open lironbar opened this issue 5 years ago • 5 comments

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?

lironbar avatar Aug 21 '18 08:08 lironbar

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

neeraj-gupta avatar Aug 21 '18 19:08 neeraj-gupta

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

danthul avatar Aug 27 '18 14:08 danthul

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.

nmccready avatar Aug 27 '18 15:08 nmccready

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

lironbar avatar Sep 05 '18 15:09 lironbar

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

danthul avatar Sep 06 '18 20:09 danthul