File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,8 @@ module.exports = {
9090 topojsonURL : 'https://cdn.plot.ly/' ,
9191
9292 // 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.
9395 mapboxAccessToken : null ,
9496
9597 // 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) {
135135 var fullLayout = gd . _fullLayout ,
136136 context = gd . _context ;
137137
138+ // special case for Mapbox Atlas users
139+ if ( context . mapboxAccessToken === '' ) return '' ;
140+
138141 // first look for access token in context
139142 var accessToken = context . mapboxAccessToken ;
140143
Original file line number Diff line number Diff line change @@ -245,6 +245,32 @@ describe('mapbox credentials', function() {
245245 done ( ) ;
246246 } ) ;
247247 } ) ;
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+ } ) ;
248274} ) ;
249275
250276describe ( 'mapbox plots' , function ( ) {
You can’t perform that action at this time.
0 commit comments