Skip to content

Commit 3181cbe

Browse files
committed
ensure that all tile source items are non-empty strings
1 parent e26dfc3 commit 3181cbe

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

src/plots/mapbox/layers.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,21 @@ proto.dispose = function() {
150150
};
151151

152152
function isVisible(opts) {
153+
if(!opts.visible) return false;
154+
153155
var source = opts.source;
154156

155-
return opts.visible && (
156-
Lib.isPlainObject(source) ||
157-
((typeof source === 'string' || Array.isArray(source)) && source.length > 0)
158-
);
157+
if(Array.isArray(source) && source.length > 0) {
158+
for(var i = 0; i < source.length; i++) {
159+
if(typeof source[i] !== 'string' || source[i].length === 0) {
160+
return false;
161+
}
162+
}
163+
return true;
164+
}
165+
166+
return Lib.isPlainObject(source) ||
167+
(typeof source === 'string' && source.length > 0);
159168
}
160169

161170
function convertOpts(opts) {

test/jasmine/tests/mapbox_test.js

+18
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,24 @@ describe('@noCI, mapbox plots', function() {
998998
.then(done);
999999
}, LONG_TIMEOUT_INTERVAL);
10001000

1001+
it('@gl should validate layout layer input', function(done) {
1002+
Plotly.newPlot(gd, [{type: 'scattermapbox'}], {
1003+
mapbox: {
1004+
layers: [{
1005+
sourcetype: 'raster',
1006+
source: ['']
1007+
}]
1008+
}
1009+
})
1010+
.then(function() {
1011+
var mapInfo = getMapInfo(gd);
1012+
expect(mapInfo.layoutLayers.length).toBe(0, 'no on-map layer');
1013+
expect(mapInfo.layoutSources.length).toBe(0, 'no map source');
1014+
})
1015+
.catch(failTest)
1016+
.then(done);
1017+
}, LONG_TIMEOUT_INTERVAL);
1018+
10011019
it('@gl should be able to update the access token', function(done) {
10021020
Plotly.relayout(gd, 'mapbox.accesstoken', 'wont-work').catch(function(err) {
10031021
expect(gd._fullLayout.mapbox.accesstoken).toEqual('wont-work');

0 commit comments

Comments
 (0)