File tree 3 files changed +31
-0
lines changed
3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,8 @@ module.exports = {
90
90
topojsonURL : 'https://cdn.plot.ly/' ,
91
91
92
92
// Mapbox access token (required to plot mapbox trace types)
93
+ // If using an Mapbox Atlas server, set this option to '',
94
+ // so that plotly.js won't attempt to authenticate to the public Mapbox server.
93
95
mapboxAccessToken : null ,
94
96
95
97
// Turn all console logging on or off (errors will be thrown)
Original file line number Diff line number Diff line change @@ -135,6 +135,9 @@ function findAccessToken(gd, mapboxIds) {
135
135
var fullLayout = gd . _fullLayout ,
136
136
context = gd . _context ;
137
137
138
+ // special case for Mapbox Atlas users
139
+ if ( context . mapboxAccessToken === '' ) return '' ;
140
+
138
141
// first look for access token in context
139
142
var accessToken = context . mapboxAccessToken ;
140
143
Original file line number Diff line number Diff line change @@ -245,6 +245,32 @@ describe('mapbox credentials', function() {
245
245
done ( ) ;
246
246
} ) ;
247
247
} ) ;
248
+
249
+ it ( 'should bypass access token in mapbox layout options when config points to an Atlas server' , function ( done ) {
250
+ var cnt = 0 ;
251
+ var msg = [
252
+ 'An API access token is required to use Mapbox GL.' ,
253
+ 'See https://www.mapbox.com/developers/api/#access-tokens'
254
+ ] . join ( ' ' ) ;
255
+
256
+ Plotly . plot ( gd , [ {
257
+ type : 'scattermapbox' ,
258
+ lon : [ 10 , 20 , 30 ] ,
259
+ lat : [ 10 , 20 , 30 ]
260
+ } ] , {
261
+ mapbox : {
262
+ accesstoken : MAPBOX_ACCESS_TOKEN
263
+ }
264
+ } , {
265
+ mapboxAccessToken : ''
266
+ } ) . catch ( function ( err ) {
267
+ cnt ++ ;
268
+ expect ( err ) . toEqual ( new Error ( msg ) ) ;
269
+ } ) . then ( function ( ) {
270
+ expect ( cnt ) . toEqual ( 1 ) ;
271
+ done ( ) ;
272
+ } ) ;
273
+ } ) ;
248
274
} ) ;
249
275
250
276
describe ( 'mapbox plots' , function ( ) {
You can’t perform that action at this time.
0 commit comments