@@ -28,17 +28,10 @@ function ScatterMapbox(mapbox, uid) {
2828 this . idLayerCircle = uid + '-layer-circle' ;
2929 this . idLayerSymbol = uid + '-layer-symbol' ;
3030
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 ) ;
4235
4336 this . map . addLayer ( {
4437 id : this . idLayerFill ,
@@ -73,7 +66,6 @@ var proto = ScatterMapbox.prototype;
7366
7467proto . update = function update ( calcTrace ) {
7568 var mapbox = this . mapbox ;
76-
7769 var opts = convert ( calcTrace ) ;
7870
7971 mapbox . setOptions ( this . idLayerFill , 'setLayoutProperty' , opts . fill . layout ) ;
@@ -82,22 +74,22 @@ proto.update = function update(calcTrace) {
8274 mapbox . setOptions ( this . idLayerSymbol , 'setLayoutProperty' , opts . symbol . layout ) ;
8375
8476 if ( isVisible ( opts . fill ) ) {
85- this . sourceFill . setData ( opts . fill . geojson ) ;
77+ mapbox . setSourceData ( this . idSourceFill , opts . fill . geojson ) ;
8678 mapbox . setOptions ( this . idLayerFill , 'setPaintProperty' , opts . fill . paint ) ;
8779 }
8880
8981 if ( isVisible ( opts . line ) ) {
90- this . sourceLine . setData ( opts . line . geojson ) ;
82+ mapbox . setSourceData ( this . idSourceLine , opts . line . geojson ) ;
9183 mapbox . setOptions ( this . idLayerLine , 'setPaintProperty' , opts . line . paint ) ;
9284 }
9385
9486 if ( isVisible ( opts . circle ) ) {
95- this . sourceCircle . setData ( opts . circle . geojson ) ;
87+ mapbox . setSourceData ( this . idSourceCircle , opts . circle . geojson ) ;
9688 mapbox . setOptions ( this . idLayerCircle , 'setPaintProperty' , opts . circle . paint ) ;
9789 }
9890
9991 if ( isVisible ( opts . symbol ) ) {
100- this . sourceSymbol . setData ( opts . symbol . geojson ) ;
92+ mapbox . setSourceData ( this . idSourceSymbol , opts . symbol . geojson ) ;
10193 mapbox . setOptions ( this . idLayerSymbol , 'setPaintProperty' , opts . symbol . paint ) ;
10294 }
10395} ;
0 commit comments