Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
include mapbox.style value that start by mapbox://
... in list that require mapbox access token
  • Loading branch information
etpinard committed Aug 21, 2019
commit e5c3b4137eb3cd3b332a83c15179ac69ba32b3d1
5 changes: 4 additions & 1 deletion src/plots/mapbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,10 @@ function findAccessToken(gd, mapboxIds) {
}

function isMapboxStyle(s) {
return typeof s === 'string' && constants.styleValuesMapbox.indexOf(s) !== -1;
return typeof s === 'string' && (
constants.styleValuesMapbox.indexOf(s) !== -1 ||
s.indexOf('mapbox://') === 0
);
}

exports.updateFx = function(gd) {
Expand Down
21 changes: 21 additions & 0 deletions test/jasmine/tests/mapbox_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,27 @@ describe('mapbox credentials', function() {
});
}, LONG_TIMEOUT_INTERVAL);

it('@gl should not throw when using a custom mapbox style URL with an access token in the layout', function(done) {
var cnt = 0;

Plotly.plot(gd, [{
type: 'scattermapbox',
lon: [10, 20, 30],
lat: [10, 20, 30]
}], {
mapbox: {
accesstoken: MAPBOX_ACCESS_TOKEN,
style: 'mapbox://styles/etpinard/cip93fm98000sbmnuednknloo'
}
}).catch(function() {
cnt++;
}).then(function() {
expect(cnt).toEqual(0);
expect(gd._fullLayout.mapbox.accesstoken).toBe(MAPBOX_ACCESS_TOKEN);
done();
});
}, LONG_TIMEOUT_INTERVAL);

it('@gl should log when an access token is set while using a custom non-mapbox style', function(done) {
spyOn(Lib, 'log');
var cnt = 0;
Expand Down