@@ -4,6 +4,7 @@ import { BaseVectorElement, VectorElementVector } from '../vectorelements';
4
4
import { GeometrySimplifier } from '../geometry/simplifier' ;
5
5
import { FeatureCollection } from '../geometry/feature' ;
6
6
import { fromNativeMapBounds } from '../core' ;
7
+ import { featureCollectionFromArgs , styleFromArgs } from '..' ;
7
8
8
9
export abstract class VectorDataSource < T extends com . carto . datasources . VectorDataSource , U extends LocalVectorDataSourceOptions > extends DataSource < T , U > {
9
10
// createNative(options: U) {
@@ -16,22 +17,20 @@ export class LocalVectorDataSource extends VectorDataSource<com.carto.datasource
16
17
}
17
18
add ( element : BaseVectorElement < any , any > ) {
18
19
// a native element could have been passed
19
- const nativeObj = element . getNative ? element . getNative ( ) : element ;
20
+ const nativeObj = element . getNative ? element . getNative ( ) : element ;
20
21
if ( nativeObj instanceof com . carto . vectorelements . VectorElementVector ) {
21
22
this . getNative ( ) . addAll ( nativeObj ) ;
22
23
} else {
23
24
this . getNative ( ) . add ( nativeObj as com . carto . vectorelements . VectorElement ) ;
24
-
25
25
}
26
26
}
27
27
remove ( element : BaseVectorElement < any , any > ) {
28
28
// a native element could have been passed
29
- const nativeObj = element . getNative ? element . getNative ( ) : element ;
29
+ const nativeObj = element . getNative ? element . getNative ( ) : element ;
30
30
if ( nativeObj instanceof com . carto . vectorelements . VectorElementVector ) {
31
31
this . getNative ( ) . removeAll ( nativeObj ) ;
32
32
} else {
33
33
this . getNative ( ) . remove ( nativeObj as com . carto . vectorelements . VectorElement ) ;
34
-
35
34
}
36
35
}
37
36
addAll ( elements : VectorElementVector ) {
@@ -46,8 +45,8 @@ export class LocalVectorDataSource extends VectorDataSource<com.carto.datasource
46
45
clear ( ) {
47
46
this . getNative ( ) . clear ( ) ;
48
47
}
49
- addFeatureCollection ( featureCollection : FeatureCollection , style : com . carto . styles . Style ) {
50
- this . getNative ( ) . addFeatureCollection ( featureCollection . getNative ( ) , style ) ;
48
+ addFeatureCollection ( featureCollection : FeatureCollection , style : any ) {
49
+ this . getNative ( ) . addFeatureCollection ( featureCollectionFromArgs ( featureCollection ) , styleFromArgs ( style ) ) ;
51
50
}
52
51
53
52
getDataExtent ( ) {
0 commit comments