Skip to content

Commit e5c3b41

Browse files
committed
include mapbox.style value that start by mapbox://
... in list that require mapbox access token
1 parent 2aec9ef commit e5c3b41

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

Diff for: src/plots/mapbox/index.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,10 @@ function findAccessToken(gd, mapboxIds) {
270270
}
271271

272272
function isMapboxStyle(s) {
273-
return typeof s === 'string' && constants.styleValuesMapbox.indexOf(s) !== -1;
273+
return typeof s === 'string' && (
274+
constants.styleValuesMapbox.indexOf(s) !== -1 ||
275+
s.indexOf('mapbox://') === 0
276+
);
274277
}
275278

276279
exports.updateFx = function(gd) {

Diff for: test/jasmine/tests/mapbox_test.js

+21
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,27 @@ describe('mapbox credentials', function() {
399399
});
400400
}, LONG_TIMEOUT_INTERVAL);
401401

402+
it('@gl should not throw when using a custom mapbox style URL with an access token in the layout', function(done) {
403+
var cnt = 0;
404+
405+
Plotly.plot(gd, [{
406+
type: 'scattermapbox',
407+
lon: [10, 20, 30],
408+
lat: [10, 20, 30]
409+
}], {
410+
mapbox: {
411+
accesstoken: MAPBOX_ACCESS_TOKEN,
412+
style: 'mapbox://styles/etpinard/cip93fm98000sbmnuednknloo'
413+
}
414+
}).catch(function() {
415+
cnt++;
416+
}).then(function() {
417+
expect(cnt).toEqual(0);
418+
expect(gd._fullLayout.mapbox.accesstoken).toBe(MAPBOX_ACCESS_TOKEN);
419+
done();
420+
});
421+
}, LONG_TIMEOUT_INTERVAL);
422+
402423
it('@gl should log when an access token is set while using a custom non-mapbox style', function(done) {
403424
spyOn(Lib, 'log');
404425
var cnt = 0;

0 commit comments

Comments
 (0)