Skip to content

Commit 48d5fea

Browse files
committed
fix: LocalVectorLayer addFeatureCollection fix
1 parent 34fcfa8 commit 48d5fea

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/datasources/vector.android.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { BaseVectorElement, VectorElementVector } from '../vectorelements';
44
import { GeometrySimplifier } from '../geometry/simplifier';
55
import { FeatureCollection } from '../geometry/feature';
66
import { fromNativeMapBounds } from '../core';
7+
import { featureCollectionFromArgs, styleFromArgs } from '..';
78

89
export abstract class VectorDataSource<T extends com.carto.datasources.VectorDataSource, U extends LocalVectorDataSourceOptions> extends DataSource<T, U> {
910
// createNative(options: U) {
@@ -16,22 +17,20 @@ export class LocalVectorDataSource extends VectorDataSource<com.carto.datasource
1617
}
1718
add(element: BaseVectorElement<any, any>) {
1819
// a native element could have been passed
19-
const nativeObj = element.getNative ? element.getNative(): element;
20+
const nativeObj = element.getNative ? element.getNative() : element;
2021
if (nativeObj instanceof com.carto.vectorelements.VectorElementVector) {
2122
this.getNative().addAll(nativeObj);
2223
} else {
2324
this.getNative().add(nativeObj as com.carto.vectorelements.VectorElement);
24-
2525
}
2626
}
2727
remove(element: BaseVectorElement<any, any>) {
2828
// a native element could have been passed
29-
const nativeObj = element.getNative ? element.getNative(): element;
29+
const nativeObj = element.getNative ? element.getNative() : element;
3030
if (nativeObj instanceof com.carto.vectorelements.VectorElementVector) {
3131
this.getNative().removeAll(nativeObj);
3232
} else {
3333
this.getNative().remove(nativeObj as com.carto.vectorelements.VectorElement);
34-
3534
}
3635
}
3736
addAll(elements: VectorElementVector) {
@@ -46,8 +45,8 @@ export class LocalVectorDataSource extends VectorDataSource<com.carto.datasource
4645
clear() {
4746
this.getNative().clear();
4847
}
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));
5150
}
5251

5352
getDataExtent() {

src/datasources/vector.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ export class LocalVectorDataSource<T = DefaultLatLonKeys> extends VectorDataSour
1818
setGeometrySimplifier(simplifier: GeometrySimplifier<any, any>);
1919
clear();
2020
addFeatureCollection(featureCollection: FeatureCollection, style: any);
21-
getDataExtent(): MapBounds<T>
21+
getDataExtent(): MapBounds<T>;
2222
}

src/datasources/vector.ios.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { BaseVectorElement, VectorElementVector } from '../vectorelements';
44
import { GeometrySimplifier } from '../geometry/simplifier';
55
import { FeatureCollection } from '../geometry/feature';
66
import { fromNativeMapBounds } from '../core';
7+
import { featureCollectionFromArgs, styleFromArgs } from '..';
78

89
export abstract class VectorDataSource<T extends NTVectorDataSource, U extends LocalVectorDataSourceOptions> extends DataSource<T, U> {
910
// createNative(options: U) {
@@ -33,8 +34,8 @@ export class LocalVectorDataSource extends VectorDataSource<NTLocalVectorDataSou
3334
clear() {
3435
this.getNative().clear();
3536
}
36-
addFeatureCollection(featureCollection: FeatureCollection, style: NTStyle) {
37-
this.getNative().addFeatureCollectionStyle(featureCollection.getNative(), style);
37+
addFeatureCollection(featureCollection: FeatureCollection, style: any) {
38+
this.getNative().addFeatureCollectionStyle(featureCollectionFromArgs(featureCollection), styleFromArgs(style));
3839
}
3940
addAll(elements: VectorElementVector) {
4041
this.getNative().addAll(elements.getNative() as NTVectorElementVector);

0 commit comments

Comments
 (0)