@@ -85,6 +85,10 @@ proto.needsNewLayer = function(opts) {
85
85
) ;
86
86
} ;
87
87
88
+ proto . lookupBelow = function ( ) {
89
+ return this . subplot . belowLookup [ 'layout-' + this . index ] ;
90
+ } ;
91
+
88
92
proto . updateImage = function ( opts ) {
89
93
var map = this . subplot . map ;
90
94
map . getSource ( this . idSource ) . updateImage ( {
@@ -107,29 +111,29 @@ proto.updateSource = function(opts) {
107
111
map . addSource ( this . idSource , sourceOpts ) ;
108
112
} ;
109
113
110
- proto . updateLayer = function ( opts ) {
111
- var subplot = this . subplot ;
112
- var convertedOpts = convertOpts ( opts ) ;
113
-
114
- var below = this . subplot . belowLookup [ 'layout-' + this . index ] ;
115
- var _below ;
116
-
114
+ proto . findFollowingMapboxLayerId = function ( below ) {
117
115
if ( below === 'traces' ) {
118
- var mapLayers = subplot . getMapLayers ( ) ;
116
+ var mapLayers = this . subplot . getMapLayers ( ) ;
119
117
120
118
// find id of first plotly trace layer
121
119
for ( var i = 0 ; i < mapLayers . length ; i ++ ) {
122
120
var layerId = mapLayers [ i ] . id ;
123
121
if ( typeof layerId === 'string' &&
124
122
layerId . indexOf ( constants . traceLayerPrefix ) === 0
125
123
) {
126
- _below = layerId ;
124
+ below = layerId ;
127
125
break ;
128
126
}
129
127
}
130
- } else {
131
- _below = below ;
132
128
}
129
+ return below ;
130
+ } ;
131
+
132
+ proto . updateLayer = function ( opts ) {
133
+ var subplot = this . subplot ;
134
+ var convertedOpts = convertOpts ( opts ) ;
135
+ var below = this . lookupBelow ( ) ;
136
+ var _below = this . findFollowingMapboxLayerId ( below ) ;
133
137
134
138
this . removeLayer ( ) ;
135
139
0 commit comments