@@ -53,7 +53,7 @@ exports.supplyLayoutDefaults = require('./layout_defaults');
53
53
var firstPlot = true ;
54
54
55
55
exports . plot = function plot ( gd ) {
56
- if ( firstPlot ) {
56
+ if ( firstPlot ) {
57
57
firstPlot = false ;
58
58
Lib . warn ( deprecationWarning ) ;
59
59
}
@@ -62,25 +62,25 @@ exports.plot = function plot(gd) {
62
62
var calcData = gd . calcdata ;
63
63
var mapboxIds = fullLayout . _subplots [ MAPBOX ] ;
64
64
65
- if ( mapboxgl . version !== constants . requiredVersion ) {
65
+ if ( mapboxgl . version !== constants . requiredVersion ) {
66
66
throw new Error ( constants . wrongVersionErrorMsg ) ;
67
67
}
68
68
69
69
var accessToken = findAccessToken ( gd , mapboxIds ) ;
70
70
mapboxgl . accessToken = accessToken ;
71
71
72
- for ( var i = 0 ; i < mapboxIds . length ; i ++ ) {
72
+ for ( var i = 0 ; i < mapboxIds . length ; i ++ ) {
73
73
var id = mapboxIds [ i ] ;
74
74
var subplotCalcData = getSubplotCalcData ( calcData , MAPBOX , id ) ;
75
75
var opts = fullLayout [ id ] ;
76
76
var mapbox = opts . _subplot ;
77
77
78
- if ( ! mapbox ) {
78
+ if ( ! mapbox ) {
79
79
mapbox = new Mapbox ( gd , id ) ;
80
80
fullLayout [ id ] . _subplot = mapbox ;
81
81
}
82
82
83
- if ( ! mapbox . viewInitial ) {
83
+ if ( ! mapbox . viewInitial ) {
84
84
mapbox . viewInitial = {
85
85
center : Lib . extendFlat ( { } , opts . center ) ,
86
86
zoom : opts . zoom ,
@@ -93,24 +93,24 @@ exports.plot = function plot(gd) {
93
93
}
94
94
} ;
95
95
96
- exports . clean = function ( newFullData , newFullLayout , oldFullData , oldFullLayout ) {
96
+ exports . clean = function ( newFullData , newFullLayout , oldFullData , oldFullLayout ) {
97
97
var oldMapboxKeys = oldFullLayout . _subplots [ MAPBOX ] || [ ] ;
98
98
99
- for ( var i = 0 ; i < oldMapboxKeys . length ; i ++ ) {
99
+ for ( var i = 0 ; i < oldMapboxKeys . length ; i ++ ) {
100
100
var oldMapboxKey = oldMapboxKeys [ i ] ;
101
101
102
- if ( ! newFullLayout [ oldMapboxKey ] && ! ! oldFullLayout [ oldMapboxKey ] . _subplot ) {
102
+ if ( ! newFullLayout [ oldMapboxKey ] && ! ! oldFullLayout [ oldMapboxKey ] . _subplot ) {
103
103
oldFullLayout [ oldMapboxKey ] . _subplot . destroy ( ) ;
104
104
}
105
105
}
106
106
} ;
107
107
108
- exports . toSVG = function ( gd ) {
108
+ exports . toSVG = function ( gd ) {
109
109
var fullLayout = gd . _fullLayout ;
110
110
var subplotIds = fullLayout . _subplots [ MAPBOX ] ;
111
111
var size = fullLayout . _size ;
112
112
113
- for ( var i = 0 ; i < subplotIds . length ; i ++ ) {
113
+ for ( var i = 0 ; i < subplotIds . length ; i ++ ) {
114
114
var opts = fullLayout [ subplotIds [ i ] ] ;
115
115
var domain = opts . domain ;
116
116
var mapbox = opts . _subplot ;
@@ -132,7 +132,7 @@ exports.toSVG = function (gd) {
132
132
133
133
// Append logo if visible
134
134
var hidden = subplotDiv . select ( '.mapboxgl-ctrl-logo' ) . node ( ) . offsetParent === null ;
135
- if ( ! hidden ) {
135
+ if ( ! hidden ) {
136
136
var logo = fullLayout . _glimages . append ( 'g' ) ;
137
137
logo . attr ( 'transform' , strTranslate ( size . l + size . w * domain . x [ 0 ] + 10 , size . t + size . h * ( 1 - domain . y [ 0 ] ) - 31 ) ) ;
138
138
logo . append ( 'path' )
@@ -185,7 +185,7 @@ exports.toSVG = function (gd) {
185
185
186
186
// Break into multiple lines twice larger than domain
187
187
var maxWidth = size . w * ( domain . x [ 1 ] - domain . x [ 0 ] ) ;
188
- if ( ( bBox . width > maxWidth / 2 ) ) {
188
+ if ( ( bBox . width > maxWidth / 2 ) ) {
189
189
var multilineAttributions = attributions . split ( '|' ) . join ( '<br>' ) ;
190
190
attributionText
191
191
. text ( multilineAttributions )
@@ -209,7 +209,7 @@ exports.toSVG = function (gd) {
209
209
210
210
// Scale down if larger than domain
211
211
var scaleRatio = 1 ;
212
- if ( ( bBox . width + 6 ) > maxWidth ) scaleRatio = maxWidth / ( bBox . width + 6 ) ;
212
+ if ( ( bBox . width + 6 ) > maxWidth ) scaleRatio = maxWidth / ( bBox . width + 6 ) ;
213
213
214
214
var offset = [ ( size . l + size . w * domain . x [ 1 ] ) , ( size . t + size . h * ( 1 - domain . y [ 0 ] ) ) ] ;
215
215
attributionGroup . attr ( 'transform' , strTranslate ( offset [ 0 ] , offset [ 1 ] ) + strScale ( scaleRatio ) ) ;
@@ -223,7 +223,7 @@ function findAccessToken(gd, mapboxIds) {
223
223
var context = gd . _context ;
224
224
225
225
// special case for Mapbox Atlas users
226
- if ( context . mapboxAccessToken === '' ) return '' ;
226
+ if ( context . mapboxAccessToken === '' ) return '' ;
227
227
228
228
var tokensUseful = [ ] ;
229
229
var tokensListed = [ ] ;
@@ -232,42 +232,42 @@ function findAccessToken(gd, mapboxIds) {
232
232
233
233
// Take the first token we find in a mapbox subplot.
234
234
// These default to the context value but may be overridden.
235
- for ( var i = 0 ; i < mapboxIds . length ; i ++ ) {
235
+ for ( var i = 0 ; i < mapboxIds . length ; i ++ ) {
236
236
var opts = fullLayout [ mapboxIds [ i ] ] ;
237
237
var token = opts . accesstoken ;
238
238
239
- if ( isStyleRequireAccessToken ( opts . style ) ) {
240
- if ( token ) {
239
+ if ( isStyleRequireAccessToken ( opts . style ) ) {
240
+ if ( token ) {
241
241
Lib . pushUnique ( tokensUseful , token ) ;
242
242
} else {
243
- if ( isStyleRequireAccessToken ( opts . _input . style ) ) {
243
+ if ( isStyleRequireAccessToken ( opts . _input . style ) ) {
244
244
Lib . error ( 'Uses Mapbox map style, but did not set an access token.' ) ;
245
245
hasOneSetMapboxStyle = true ;
246
246
}
247
247
wontWork = true ;
248
248
}
249
249
}
250
250
251
- if ( token ) {
251
+ if ( token ) {
252
252
Lib . pushUnique ( tokensListed , token ) ;
253
253
}
254
254
}
255
255
256
- if ( wontWork ) {
256
+ if ( wontWork ) {
257
257
var msg = hasOneSetMapboxStyle ?
258
258
constants . noAccessTokenErrorMsg :
259
259
constants . missingStyleErrorMsg ;
260
260
Lib . error ( msg ) ;
261
261
throw new Error ( msg ) ;
262
262
}
263
263
264
- if ( tokensUseful . length ) {
265
- if ( tokensUseful . length > 1 ) {
264
+ if ( tokensUseful . length ) {
265
+ if ( tokensUseful . length > 1 ) {
266
266
Lib . warn ( constants . multipleTokensErrorMsg ) ;
267
267
}
268
268
return tokensUseful [ 0 ] ;
269
269
} else {
270
- if ( tokensListed . length ) {
270
+ if ( tokensListed . length ) {
271
271
Lib . log ( [
272
272
'Listed mapbox access token(s)' , tokensListed . join ( ',' ) ,
273
273
'but did not use a Mapbox map style, ignoring token(s).'
@@ -285,11 +285,11 @@ function isStyleRequireAccessToken(s) {
285
285
) ;
286
286
}
287
287
288
- exports . updateFx = function ( gd ) {
288
+ exports . updateFx = function ( gd ) {
289
289
var fullLayout = gd . _fullLayout ;
290
290
var subplotIds = fullLayout . _subplots [ MAPBOX ] ;
291
291
292
- for ( var i = 0 ; i < subplotIds . length ; i ++ ) {
292
+ for ( var i = 0 ; i < subplotIds . length ; i ++ ) {
293
293
var subplotObj = fullLayout [ subplotIds [ i ] ] . _subplot ;
294
294
subplotObj . updateFx ( fullLayout ) ;
295
295
}
0 commit comments