@@ -86,7 +86,7 @@ proto.createMap = function(calcData, fullLayout, resolve, reject) {
8686 var opts = fullLayout [ self . id ] ;
8787
8888 // store style id and URL or object
89- var styleObj = self . styleObj = getStyleObj ( opts . style ) ;
89+ var styleObj = self . styleObj = getStyleObj ( opts . style , fullLayout ) ;
9090
9191 // store access token associated with this map
9292 self . accessToken = opts . accesstoken ;
@@ -152,7 +152,7 @@ proto.updateMap = function(calcData, fullLayout, resolve, reject) {
152152 self . rejectOnError ( reject ) ;
153153
154154 var promises = [ ] ;
155- var styleObj = getStyleObj ( opts . style ) ;
155+ var styleObj = getStyleObj ( opts . style , fullLayout ) ;
156156
157157 if ( JSON . stringify ( self . styleObj ) !== JSON . stringify ( styleObj ) ) {
158158 self . styleObj = styleObj ;
@@ -768,7 +768,7 @@ proto.getViewEditsWithDerived = function(cont) {
768768 return obj ;
769769} ;
770770
771- function getStyleObj ( val ) {
771+ function getStyleObj ( val , fullLayout ) {
772772 var styleObj = { } ;
773773
774774 if ( Lib . isPlainObject ( val ) ) {
@@ -781,6 +781,16 @@ function getStyleObj(val) {
781781 styleObj . style = convertStyleVal ( val ) ;
782782 } else if ( constants . stylesNonMapbox [ val ] ) {
783783 styleObj . style = constants . stylesNonMapbox [ val ] ;
784+ var spec = styleObj . style . sources [ 'plotly-' + val ] ;
785+ var tiles = spec ? spec . tiles : undefined ;
786+ if (
787+ tiles &&
788+ tiles [ 0 ] &&
789+ tiles [ 0 ] . slice ( - 9 ) === '?api_key='
790+ ) {
791+ // provide api_key for stamen styles
792+ tiles [ 0 ] += fullLayout . _mapboxAccessToken ;
793+ }
784794 } else {
785795 styleObj . style = val ;
786796 }
0 commit comments