@@ -28,17 +28,10 @@ function ScatterMapbox(mapbox, uid) {
28
28
this . idLayerCircle = uid + '-layer-circle' ;
29
29
this . idLayerSymbol = uid + '-layer-symbol' ;
30
30
31
- this . sourceFill = mapbox . createGeoJSONSource ( ) ;
32
- this . map . addSource ( this . idSourceFill , this . sourceFill ) ;
33
-
34
- this . sourceLine = mapbox . createGeoJSONSource ( ) ;
35
- this . map . addSource ( this . idSourceLine , this . sourceLine ) ;
36
-
37
- this . sourceCircle = mapbox . createGeoJSONSource ( ) ;
38
- this . map . addSource ( this . idSourceCircle , this . sourceCircle ) ;
39
-
40
- this . sourceSymbol = mapbox . createGeoJSONSource ( ) ;
41
- this . map . addSource ( this . idSourceSymbol , this . sourceSymbol ) ;
31
+ this . mapbox . initSource ( this . idSourceFill ) ;
32
+ this . mapbox . initSource ( this . idSourceLine ) ;
33
+ this . mapbox . initSource ( this . idSourceCircle ) ;
34
+ this . mapbox . initSource ( this . idSourceSymbol ) ;
42
35
43
36
this . map . addLayer ( {
44
37
id : this . idLayerFill ,
@@ -73,7 +66,6 @@ var proto = ScatterMapbox.prototype;
73
66
74
67
proto . update = function update ( calcTrace ) {
75
68
var mapbox = this . mapbox ;
76
-
77
69
var opts = convert ( calcTrace ) ;
78
70
79
71
mapbox . setOptions ( this . idLayerFill , 'setLayoutProperty' , opts . fill . layout ) ;
@@ -82,22 +74,22 @@ proto.update = function update(calcTrace) {
82
74
mapbox . setOptions ( this . idLayerSymbol , 'setLayoutProperty' , opts . symbol . layout ) ;
83
75
84
76
if ( isVisible ( opts . fill ) ) {
85
- this . sourceFill . setData ( opts . fill . geojson ) ;
77
+ mapbox . setSourceData ( this . idSourceFill , opts . fill . geojson ) ;
86
78
mapbox . setOptions ( this . idLayerFill , 'setPaintProperty' , opts . fill . paint ) ;
87
79
}
88
80
89
81
if ( isVisible ( opts . line ) ) {
90
- this . sourceLine . setData ( opts . line . geojson ) ;
82
+ mapbox . setSourceData ( this . idSourceLine , opts . line . geojson ) ;
91
83
mapbox . setOptions ( this . idLayerLine , 'setPaintProperty' , opts . line . paint ) ;
92
84
}
93
85
94
86
if ( isVisible ( opts . circle ) ) {
95
- this . sourceCircle . setData ( opts . circle . geojson ) ;
87
+ mapbox . setSourceData ( this . idSourceCircle , opts . circle . geojson ) ;
96
88
mapbox . setOptions ( this . idLayerCircle , 'setPaintProperty' , opts . circle . paint ) ;
97
89
}
98
90
99
91
if ( isVisible ( opts . symbol ) ) {
100
- this . sourceSymbol . setData ( opts . symbol . geojson ) ;
92
+ mapbox . setSourceData ( this . idSourceSymbol , opts . symbol . geojson ) ;
101
93
mapbox . setOptions ( this . idLayerSymbol , 'setPaintProperty' , opts . symbol . paint ) ;
102
94
}
103
95
} ;
0 commit comments