Skip to content

Commit ed6634c

Browse files
dmytro-gokunWykks
authored andcommitted
feat: update to mapbox-gl 0.53.1 and fix compilation errors (#128)
* Fix linter's warnings * Fix compilation errors and update to mapbox-gl 0.53.1
1 parent a611858 commit ed6634c

File tree

11 files changed

+9593
-10422
lines changed

11 files changed

+9593
-10422
lines changed

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,25 @@
4040
"@turf/random": "^6.0.2",
4141
"hammerjs": "^2.0.8",
4242
"lodash-es": "^4.17.11",
43-
"mapbox-gl": "0.52.0",
43+
"mapbox-gl": "0.53.1",
4444
"ngx-md": "^7.0.0",
4545
"rxjs": "^6.3.3",
4646
"scroll-into-view-if-needed": "^2.2.20",
4747
"zone.js": "^0.8.29"
4848
},
4949
"devDependencies": {
50-
"@angular-devkit/build-angular": "~0.12.0",
51-
"@angular-devkit/build-ng-packagr": "~0.12.0",
52-
"@angular/cli": "7.2.3",
50+
"@angular-devkit/build-angular": "~0.13.0",
51+
"@angular-devkit/build-ng-packagr": "~0.13.0",
52+
"@angular/cli": "^7.2.3",
5353
"@angular/compiler-cli": "^7.2.2",
5454
"@ngrx/schematics": "^7.1.0",
5555
"@turf/bbox": "^6.0.1",
5656
"@types/jasmine": "^3.3.8",
5757
"@types/jasminewd2": "^2.0.6",
5858
"@types/lodash-es": "^4.17.1",
5959
"@types/mapbox-gl": "^0.51.3",
60-
"@types/node": "^10.12.18",
61-
"@types/supercluster": "^3.0.2",
60+
"@types/node": "^11.13.0",
61+
"@types/supercluster": "^5.0.1",
6262
"codelyzer": "^4.5.0",
6363
"jasmine-core": "^3.3.0",
6464
"jasmine-spec-reporter": "^4.2.1",

projects/ngx-mapbox-gl/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
"peerDependencies": {
2323
"@angular/common": ">= 7.2.0 < 8.0.0",
2424
"@angular/core": ">= 7.2.0 < 8.0.0",
25-
"mapbox-gl": "0.52.0",
25+
"mapbox-gl": "0.53.1",
2626
"rxjs": "^6.0.0"
2727
},
2828
"dependencies": {
2929
"@mapbox/mapbox-gl-geocoder": "^3.0.1",
3030
"@turf/bbox": "^6.0.1",
3131
"@turf/helpers": "^6.1.4",
32-
"supercluster": "^4.1.1"
32+
"supercluster": "^6.0.1"
3333
}
3434
}

projects/ngx-mapbox-gl/src/lib/control/geocoder-control.directive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { MapService } from '../map/map.service';
1616
import { GeocoderEvent } from '../map/map.types';
1717
import { ControlComponent } from './control.component';
1818

19-
//@ts-ignore
19+
// @ts-ignore
2020
import * as MapboxGeocoder from '@mapbox/mapbox-gl-geocoder';
2121

2222
export const MAPBOX_GEOCODER_API_KEY = new InjectionToken('MapboxApiKey');

projects/ngx-mapbox-gl/src/lib/map/map.service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { polygon } from '@turf/helpers';
44
import * as MapboxGl from 'mapbox-gl';
55
import { AsyncSubject, Observable, Subscription } from 'rxjs';
66
import { first } from 'rxjs/operators';
7-
import { BBox } from 'supercluster';
87
import { MapEvent, MapImageData, MapImageOptions } from './map.types';
98

109
export const MAPBOX_API_KEY = new InjectionToken('MapboxApiKey');
@@ -479,7 +478,7 @@ export class MapService {
479478
});
480479
}
481480

482-
getCurrentViewportBbox(): BBox {
481+
getCurrentViewportBbox(): GeoJSON.BBox {
483482
const canvas = this.mapInstance.getCanvas();
484483
const w = parseInt(canvas.style.width!, 10);
485484
const h = parseInt(canvas.style.height!, 10);

projects/ngx-mapbox-gl/src/lib/marker-cluster/marker-cluster.component.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
} from '@angular/core';
1818
import { fromEvent, merge, Subscription } from 'rxjs';
1919
import { startWith } from 'rxjs/operators';
20-
import supercluster, { Cluster, Options as SuperclusterOptions, Supercluster } from 'supercluster';
20+
import Supercluster, { ClusterFeature, Options } from 'supercluster';
2121
import { MapService } from '../map/map.service';
2222

2323
@Directive({ selector: 'ng-template[mglPoint]' })
@@ -63,20 +63,19 @@ export class MarkerClusterComponent implements OnChanges, OnDestroy, AfterConten
6363
@Input() nodeSize?: number;
6464
@Input() log?: boolean;
6565
@Input() reduce?: (accumulated: any, props: any) => void;
66-
@Input() initial?: () => any;
6766
@Input() map?: (props: any) => any;
6867

6968
/* Dynamic input */
7069
@Input() data: GeoJSON.FeatureCollection<GeoJSON.Point>;
7170

72-
@Output() load = new EventEmitter<Supercluster>();
71+
@Output() load = new EventEmitter<Supercluster<GeoJSON.GeoJsonProperties, GeoJSON.GeoJsonProperties>>();
7372

7473
@ContentChild(PointDirective, { read: TemplateRef }) pointTpl: TemplateRef<any>;
7574
@ContentChild(ClusterPointDirective, { read: TemplateRef }) clusterPointTpl: TemplateRef<any>;
7675

7776
clusterPoints: GeoJSON.Feature<GeoJSON.Point>[];
7877

79-
private supercluster: Supercluster;
78+
private supercluster: Supercluster<GeoJSON.GeoJsonProperties, GeoJSON.GeoJsonProperties>;
8079
private sub = new Subscription();
8180

8281
constructor(
@@ -86,25 +85,24 @@ export class MarkerClusterComponent implements OnChanges, OnDestroy, AfterConten
8685
) { }
8786

8887
ngOnInit() {
89-
const options: SuperclusterOptions = {
88+
const options: Options<GeoJSON.GeoJsonProperties, GeoJSON.GeoJsonProperties> = {
9089
radius: this.radius,
9190
maxZoom: this.maxZoom,
9291
minZoom: this.minZoom,
9392
extent: this.extent,
9493
nodeSize: this.nodeSize,
9594
log: this.log,
9695
reduce: this.reduce,
97-
initial: this.initial,
9896
map: this.map
9997
};
10098
Object.keys(options)
10199
.forEach((key: string) => {
102-
const tkey = <keyof SuperclusterOptions>key;
100+
const tkey = <keyof Options<GeoJSON.GeoJsonProperties, GeoJSON.GeoJsonProperties>>key;
103101
if (options[tkey] === undefined) {
104102
delete options[tkey];
105103
}
106104
});
107-
this.supercluster = supercluster(options);
105+
this.supercluster = new Supercluster<GeoJSON.GeoJsonProperties, GeoJSON.GeoJsonProperties>(options);
108106
this.supercluster.load(this.data.features);
109107
this.load.emit(this.supercluster);
110108
}
@@ -137,15 +135,15 @@ export class MarkerClusterComponent implements OnChanges, OnDestroy, AfterConten
137135
this.sub.unsubscribe();
138136
}
139137

140-
getLeavesFn = (feature: Cluster) => {
138+
getLeavesFn = (feature: ClusterFeature<GeoJSON.GeoJsonProperties>) => {
141139
return (limit?: number, offset?: number) => (<any>this.supercluster.getLeaves)(feature.properties.cluster_id!, limit, offset);
142140
}
143141

144-
getChildrenFn = (feature: Cluster) => {
142+
getChildrenFn = (feature: ClusterFeature<GeoJSON.GeoJsonProperties>) => {
145143
return () => (<any>this.supercluster.getChildren)(feature.properties.cluster_id!);
146144
}
147145

148-
getClusterExpansionZoomFn = (feature: Cluster) => {
146+
getClusterExpansionZoomFn = (feature: ClusterFeature<GeoJSON.GeoJsonProperties>) => {
149147
return () => (<any>this.supercluster.getClusterExpansionZoom)(feature.properties.cluster_id!);
150148
}
151149

projects/ngx-mapbox-gl/src/lib/marker/marker.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ export class MarkerComponent implements OnChanges, OnDestroy, AfterViewInit, OnI
6767
this.markerInstance!.setDraggable(!!this.draggable);
6868
}
6969
if (changes.popupShown && !changes.popupShown.isFirstChange()) {
70-
changes.popupShown.currentValue ? this.markerInstance!.getPopup().addTo(this.MapService.mapInstance) : this.markerInstance!.getPopup().remove();
70+
changes.popupShown.currentValue
71+
? this.markerInstance!.getPopup().addTo(this.MapService.mapInstance)
72+
: this.markerInstance!.getPopup().remove();
7173
}
7274
}
7375

0 commit comments

Comments
 (0)