@@ -17,7 +17,7 @@ import {
17
17
} from '@angular/core' ;
18
18
import { fromEvent , merge , Subscription } from 'rxjs' ;
19
19
import { startWith } from 'rxjs/operators' ;
20
- import supercluster , { Cluster , Options as SuperclusterOptions , Supercluster } from 'supercluster' ;
20
+ import Supercluster , { ClusterFeature , Options } from 'supercluster' ;
21
21
import { MapService } from '../map/map.service' ;
22
22
23
23
@Directive ( { selector : 'ng-template[mglPoint]' } )
@@ -63,20 +63,19 @@ export class MarkerClusterComponent implements OnChanges, OnDestroy, AfterConten
63
63
@Input ( ) nodeSize ?: number ;
64
64
@Input ( ) log ?: boolean ;
65
65
@Input ( ) reduce ?: ( accumulated : any , props : any ) => void ;
66
- @Input ( ) initial ?: ( ) => any ;
67
66
@Input ( ) map ?: ( props : any ) => any ;
68
67
69
68
/* Dynamic input */
70
69
@Input ( ) data : GeoJSON . FeatureCollection < GeoJSON . Point > ;
71
70
72
- @Output ( ) load = new EventEmitter < Supercluster > ( ) ;
71
+ @Output ( ) load = new EventEmitter < Supercluster < GeoJSON . GeoJsonProperties , GeoJSON . GeoJsonProperties > > ( ) ;
73
72
74
73
@ContentChild ( PointDirective , { read : TemplateRef } ) pointTpl : TemplateRef < any > ;
75
74
@ContentChild ( ClusterPointDirective , { read : TemplateRef } ) clusterPointTpl : TemplateRef < any > ;
76
75
77
76
clusterPoints : GeoJSON . Feature < GeoJSON . Point > [ ] ;
78
77
79
- private supercluster : Supercluster ;
78
+ private supercluster : Supercluster < GeoJSON . GeoJsonProperties , GeoJSON . GeoJsonProperties > ;
80
79
private sub = new Subscription ( ) ;
81
80
82
81
constructor (
@@ -86,25 +85,24 @@ export class MarkerClusterComponent implements OnChanges, OnDestroy, AfterConten
86
85
) { }
87
86
88
87
ngOnInit ( ) {
89
- const options : SuperclusterOptions = {
88
+ const options : Options < GeoJSON . GeoJsonProperties , GeoJSON . GeoJsonProperties > = {
90
89
radius : this . radius ,
91
90
maxZoom : this . maxZoom ,
92
91
minZoom : this . minZoom ,
93
92
extent : this . extent ,
94
93
nodeSize : this . nodeSize ,
95
94
log : this . log ,
96
95
reduce : this . reduce ,
97
- initial : this . initial ,
98
96
map : this . map
99
97
} ;
100
98
Object . keys ( options )
101
99
. forEach ( ( key : string ) => {
102
- const tkey = < keyof SuperclusterOptions > key ;
100
+ const tkey = < keyof Options < GeoJSON . GeoJsonProperties , GeoJSON . GeoJsonProperties > > key ;
103
101
if ( options [ tkey ] === undefined ) {
104
102
delete options [ tkey ] ;
105
103
}
106
104
} ) ;
107
- this . supercluster = supercluster ( options ) ;
105
+ this . supercluster = new Supercluster < GeoJSON . GeoJsonProperties , GeoJSON . GeoJsonProperties > ( options ) ;
108
106
this . supercluster . load ( this . data . features ) ;
109
107
this . load . emit ( this . supercluster ) ;
110
108
}
@@ -137,15 +135,15 @@ export class MarkerClusterComponent implements OnChanges, OnDestroy, AfterConten
137
135
this . sub . unsubscribe ( ) ;
138
136
}
139
137
140
- getLeavesFn = ( feature : Cluster ) => {
138
+ getLeavesFn = ( feature : ClusterFeature < GeoJSON . GeoJsonProperties > ) => {
141
139
return ( limit ?: number , offset ?: number ) => ( < any > this . supercluster . getLeaves ) ( feature . properties . cluster_id ! , limit , offset ) ;
142
140
}
143
141
144
- getChildrenFn = ( feature : Cluster ) => {
142
+ getChildrenFn = ( feature : ClusterFeature < GeoJSON . GeoJsonProperties > ) => {
145
143
return ( ) => ( < any > this . supercluster . getChildren ) ( feature . properties . cluster_id ! ) ;
146
144
}
147
145
148
- getClusterExpansionZoomFn = ( feature : Cluster ) => {
146
+ getClusterExpansionZoomFn = ( feature : ClusterFeature < GeoJSON . GeoJsonProperties > ) => {
149
147
return ( ) => ( < any > this . supercluster . getClusterExpansionZoom ) ( feature . properties . cluster_id ! ) ;
150
148
}
151
149
0 commit comments