jQuery-Mapael icon indicating copy to clipboard operation
jQuery-Mapael copied to clipboard

Delete dynamically added plots and show new dynamic plots

Open ivanvitkov opened this issue 6 years ago • 1 comments

Greetings! So I have stumbled upon a problem while wanting to delete plots. I have set $('.container).trigger('update',[{deletePlotKeys:'all',newPlots: myPlots}]) , and that works but I get this error while hover over new plots: "TypeError: elem.mapElem.attrsHover is null". Can you help me with this please?

P.S. I tried "deletePlotKeys: oldPlots", but that does nothing. I'm guessing that I can't delete dynamically added plots.

ivanvitkov avatar Mar 27 '19 14:03 ivanvitkov

Mapael does this:

for (; i < opt.deletePlotKeys.length; i++) {
    if (self.plots[opt.deletePlotKeys[i]] !== undefined) {
        fnRemoveElement(self.plots[opt.deletePlotKeys[i]]);
        delete self.plots[opt.deletePlotKeys[i]];
    }
}

So you need to pass the old keys as an array:

opt = {
    deletePlotKeys: Object.keys(old_plot_points),
    newPlots: plot_points
}
$("#worldmap").trigger('update', [opt]);

Not sure why "all" doesn't work properly

chriswue avatar Jun 20 '19 01:06 chriswue