Skip to content

Commit dbf61a3

Browse files
fixed issue 6508 of plotly.js.
visible=legendonly in scattermapbox worked wrong
1 parent 3f8cfe7 commit dbf61a3

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/traces/scattermapbox/plot.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,12 @@ proto.addSource = function(k, opts, cluster) {
5656
clusterMaxZoom: cluster.maxzoom,
5757
});
5858
}
59-
60-
this.subplot.map.addSource(this.sourceIds[k], sourceOpts);
59+
var isSourceExists = this.subplot.map.getSource(this.sourceIds[k]);
60+
if (!!isSourceExists) {
61+
isSourceExists.setData(opts.geojson);
62+
} else {
63+
this.subplot.map.addSource(this.sourceIds[k], sourceOpts);
64+
}
6165
};
6266

6367
proto.setSourceData = function(k, opts) {
@@ -77,6 +81,13 @@ proto.addLayer = function(k, opts, below) {
7781
if(opts.filter) {
7882
source.filter = opts.filter;
7983
}
84+
var layerId = this.layerIds[k];
85+
var layerExist = this.subplot.getMapLayers().filter(function(mbLayer) {
86+
return mbLayer.id === layerId;
87+
})
88+
if (layerExist.length) {
89+
this.subplot.map.removeLayer(layerId);
90+
}
8091
this.subplot.addLayer(source, below);
8192
};
8293

0 commit comments

Comments
 (0)