Skip to content

Commit 1308cbe

Browse files
committed
add clean function to mapbox plot
1 parent 9a36cf6 commit 1308cbe

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/plots/mapbox/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@ exports.plot = function plot(gd) {
6868
}
6969
};
7070

71+
exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) {
72+
var oldMapboxKeys = oldFullLayout._subplots[MAPBOX] || [];
73+
74+
for(var i = 0; i < oldMapboxKeys.length; i++) {
75+
var oldMapboxKey = oldMapboxKeys[i];
76+
77+
if(!newFullLayout[oldMapboxKey] && !!oldFullLayout[oldMapboxKey]._subplot) {
78+
oldFullLayout[oldMapboxKey]._subplot.destroy();
79+
}
80+
}
81+
};
82+
7183
exports.toSVG = function(gd) {
7284
var fullLayout = gd._fullLayout;
7385
var subplotIds = fullLayout._subplots[MAPBOX];

0 commit comments

Comments
 (0)