@flowmap.gl/layers 8.0.0-alpha.2 → 8.0.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AnimatedFlowLinesLayer/AnimatedFlowLinesLayer.d.ts.map +1 -1
- package/dist/AnimatedFlowLinesLayer/AnimatedFlowLinesLayer.js +4 -5
- package/dist/FlowCirclesLayer/FlowCirclesLayer.d.ts +3 -3
- package/dist/FlowCirclesLayer/FlowCirclesLayer.d.ts.map +1 -1
- package/dist/FlowCirclesLayer/FlowCirclesLayer.js +5 -5
- package/dist/FlowCirclesLayer/FlowCirclesLayerFragment.glsl.d.ts +1 -1
- package/dist/FlowCirclesLayer/FlowCirclesLayerFragment.glsl.d.ts.map +1 -1
- package/dist/FlowCirclesLayer/FlowCirclesLayerFragment.glsl.js +14 -10
- package/dist/FlowCirclesLayer/FlowCirclesLayerVertex.glsl.d.ts +1 -1
- package/dist/FlowCirclesLayer/FlowCirclesLayerVertex.glsl.js +2 -2
- package/dist/FlowLinesLayer/FlowLinesLayer.d.ts.map +1 -1
- package/dist/FlowLinesLayer/FlowLinesLayer.js +64 -56
- package/dist/FlowLinesLayer/FlowLinesLayerVertex.glsl.d.ts +1 -1
- package/dist/FlowLinesLayer/FlowLinesLayerVertex.glsl.d.ts.map +1 -1
- package/dist/FlowLinesLayer/FlowLinesLayerVertex.glsl.js +2 -6
- package/dist/{FlowMapLayer.d.ts → FlowmapLayer.d.ts} +27 -18
- package/dist/FlowmapLayer.d.ts.map +1 -0
- package/dist/FlowmapLayer.js +344 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/types.d.ts +10 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/package.json +2 -2
- package/src/AnimatedFlowLinesLayer/AnimatedFlowLinesLayer.ts +2 -4
- package/src/FlowCirclesLayer/FlowCirclesLayer.ts +5 -5
- package/src/FlowCirclesLayer/FlowCirclesLayerFragment.glsl.ts +13 -9
- package/src/FlowCirclesLayer/FlowCirclesLayerVertex.glsl.ts +1 -1
- package/src/FlowLinesLayer/FlowLinesLayer.ts +71 -65
- package/src/FlowLinesLayer/FlowLinesLayerVertex.glsl.ts +1 -5
- package/src/{FlowMapLayer.ts → FlowmapLayer.ts} +142 -88
- package/src/index.ts +2 -2
- package/src/types.ts +12 -5
- package/dist/FlowMapLayer.d.ts.map +0 -1
- package/dist/FlowMapLayer.js +0 -310
|
@@ -19,51 +19,54 @@ import {ScatterplotLayer} from '@deck.gl/layers';
|
|
|
19
19
|
import {
|
|
20
20
|
colorAsRgba,
|
|
21
21
|
FlowLinesLayerAttributes,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
FlowmapData,
|
|
23
|
+
FlowmapDataAccessors,
|
|
24
|
+
FlowmapDataProvider,
|
|
25
25
|
getFlowLineAttributesByIndex,
|
|
26
|
-
|
|
26
|
+
getFlowmapColors,
|
|
27
27
|
getOuterCircleRadiusByIndex,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
getLocationCoordsByIndex,
|
|
29
|
+
isFlowmapData,
|
|
30
|
+
isFlowmapDataProvider,
|
|
31
31
|
LayersData,
|
|
32
|
-
|
|
33
|
-
LocationFilterMode,
|
|
32
|
+
LocalFlowmapDataProvider,
|
|
34
33
|
ViewportProps,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
AggregateFlow,
|
|
34
|
+
FlowmapAggregateAccessors,
|
|
35
|
+
FilterState,
|
|
38
36
|
} from '@flowmap.gl/data';
|
|
39
37
|
import AnimatedFlowLinesLayer from './AnimatedFlowLinesLayer';
|
|
40
38
|
import FlowCirclesLayer from './FlowCirclesLayer';
|
|
41
39
|
import FlowLinesLayer from './FlowLinesLayer';
|
|
42
40
|
import {
|
|
43
|
-
|
|
41
|
+
FlowmapLayerPickingInfo,
|
|
44
42
|
LayerProps,
|
|
45
43
|
PickingInfo,
|
|
46
44
|
PickingType,
|
|
47
45
|
} from './types';
|
|
48
46
|
|
|
49
|
-
export type
|
|
50
|
-
data
|
|
47
|
+
export type FlowmapLayerProps<L, F> = {
|
|
48
|
+
data?: FlowmapData<L, F>;
|
|
49
|
+
dataProvider?: FlowmapDataProvider<L, F>;
|
|
50
|
+
filter?: FilterState;
|
|
51
51
|
locationTotalsEnabled?: boolean;
|
|
52
52
|
adaptiveScalesEnabled?: boolean;
|
|
53
53
|
animationEnabled?: boolean;
|
|
54
54
|
clusteringEnabled?: boolean;
|
|
55
55
|
clusteringLevel?: number;
|
|
56
56
|
fadeEnabled?: boolean;
|
|
57
|
+
fadeOpacityEnabled?: boolean;
|
|
57
58
|
clusteringAuto?: boolean;
|
|
58
59
|
darkMode?: boolean;
|
|
59
60
|
fadeAmount?: number;
|
|
60
|
-
colorScheme?: string;
|
|
61
|
+
colorScheme?: string | string[];
|
|
62
|
+
highlightColor?: string | number[];
|
|
63
|
+
maxTopFlowsDisplayNum?: number;
|
|
61
64
|
onHover?: (
|
|
62
|
-
info:
|
|
65
|
+
info: FlowmapLayerPickingInfo<L, F> | undefined,
|
|
63
66
|
event: SourceEvent,
|
|
64
67
|
) => void;
|
|
65
|
-
onClick?: (info:
|
|
66
|
-
} & Partial<
|
|
68
|
+
onClick?: (info: FlowmapLayerPickingInfo<L, F>, event: SourceEvent) => void;
|
|
69
|
+
} & Partial<FlowmapDataAccessors<L, F>> &
|
|
67
70
|
LayerProps;
|
|
68
71
|
|
|
69
72
|
enum HighlightType {
|
|
@@ -73,7 +76,7 @@ enum HighlightType {
|
|
|
73
76
|
|
|
74
77
|
type HighlightedLocationObject = {
|
|
75
78
|
type: HighlightType.LOCATION;
|
|
76
|
-
|
|
79
|
+
coords: [number, number];
|
|
77
80
|
radius: number;
|
|
78
81
|
};
|
|
79
82
|
|
|
@@ -85,15 +88,16 @@ type HighlightedFlowObject = {
|
|
|
85
88
|
type HighlightedObject = HighlightedLocationObject | HighlightedFlowObject;
|
|
86
89
|
|
|
87
90
|
type State<L, F> = {
|
|
88
|
-
accessors:
|
|
89
|
-
dataProvider:
|
|
91
|
+
accessors: FlowmapAggregateAccessors<L, F>;
|
|
92
|
+
dataProvider: FlowmapDataProvider<L, F>;
|
|
90
93
|
layersData: LayersData | undefined;
|
|
91
94
|
highlightedObject: HighlightedObject | undefined;
|
|
95
|
+
pickingInfo: FlowmapLayerPickingInfo<L, F> | undefined;
|
|
92
96
|
};
|
|
93
97
|
|
|
94
98
|
export type SourceEvent = {srcEvent: MouseEvent};
|
|
95
99
|
|
|
96
|
-
export default class
|
|
100
|
+
export default class FlowmapLayer<L, F> extends CompositeLayer {
|
|
97
101
|
static defaultProps = {
|
|
98
102
|
darkMode: true,
|
|
99
103
|
fadeAmount: 50,
|
|
@@ -101,16 +105,23 @@ export default class FlowMapLayer<L, F> extends CompositeLayer {
|
|
|
101
105
|
animationEnabled: false,
|
|
102
106
|
clusteringEnabled: true,
|
|
103
107
|
fadeEnabled: true,
|
|
108
|
+
fadeOpacityEnabled: false,
|
|
104
109
|
clusteringAuto: true,
|
|
105
110
|
clusteringLevel: undefined,
|
|
106
111
|
adaptiveScalesEnabled: true,
|
|
107
112
|
colorScheme: 'Teal',
|
|
113
|
+
highlightColor: 'orange',
|
|
114
|
+
maxTopFlowsDisplayNum: 5000,
|
|
108
115
|
};
|
|
109
116
|
state: State<L, F> | undefined;
|
|
110
117
|
|
|
111
|
-
public constructor(props:
|
|
118
|
+
public constructor(props: FlowmapLayerProps<L, F>) {
|
|
112
119
|
super({
|
|
113
120
|
...props,
|
|
121
|
+
dataProvider: {
|
|
122
|
+
// To avoid deck.gl props diffing on comlink worker proxy causing an exception
|
|
123
|
+
dataProvider: props.dataProvider,
|
|
124
|
+
},
|
|
114
125
|
onHover: (info: PickingInfo<any>, event: SourceEvent) => {
|
|
115
126
|
// TODO: if (lastHoverEventStartTimeRef > startTime) {
|
|
116
127
|
// // Skipping, because this is not the latest hover event
|
|
@@ -119,15 +130,17 @@ export default class FlowMapLayer<L, F> extends CompositeLayer {
|
|
|
119
130
|
this.setState({highlightedObject: this._getHighlightedObject(info)});
|
|
120
131
|
const {onHover} = props;
|
|
121
132
|
if (onHover) {
|
|
122
|
-
this.
|
|
123
|
-
|
|
124
|
-
|
|
133
|
+
this._getFlowmapLayerPickingInfo(info).then((info) => {
|
|
134
|
+
this.setState({pickingInfo: info});
|
|
135
|
+
onHover(info, event);
|
|
136
|
+
});
|
|
125
137
|
}
|
|
126
138
|
},
|
|
127
139
|
onClick: (info: PickingInfo<any>, event: SourceEvent) => {
|
|
128
140
|
const {onClick} = props;
|
|
129
141
|
if (onClick) {
|
|
130
|
-
this.
|
|
142
|
+
this._getFlowmapLayerPickingInfo(info).then((info) => {
|
|
143
|
+
this.setState({pickingInfo: info});
|
|
131
144
|
if (info) {
|
|
132
145
|
onClick(info, event);
|
|
133
146
|
}
|
|
@@ -139,34 +152,50 @@ export default class FlowMapLayer<L, F> extends CompositeLayer {
|
|
|
139
152
|
|
|
140
153
|
initializeState() {
|
|
141
154
|
this.state = {
|
|
142
|
-
accessors: new
|
|
143
|
-
dataProvider: this.
|
|
155
|
+
accessors: new FlowmapAggregateAccessors<L, F>(this.props),
|
|
156
|
+
dataProvider: this._getOrMakeDataProvider(),
|
|
144
157
|
layersData: undefined,
|
|
145
158
|
highlightedObject: undefined,
|
|
159
|
+
pickingInfo: undefined,
|
|
146
160
|
};
|
|
147
161
|
}
|
|
148
162
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
163
|
+
getPickingInfo({info}: Record<string, any>) {
|
|
164
|
+
// This is for onHover event handlers set on the <DeckGL> component
|
|
165
|
+
if (!info.object) {
|
|
166
|
+
const object = this.state?.pickingInfo?.object;
|
|
167
|
+
if (object) {
|
|
168
|
+
return {
|
|
169
|
+
...info,
|
|
170
|
+
object,
|
|
171
|
+
picked: true,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return info;
|
|
152
176
|
}
|
|
153
177
|
|
|
154
|
-
private
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
178
|
+
// private _updateAccessors() {
|
|
179
|
+
// this.state?.dataProvider?.setAccessors(this.props);
|
|
180
|
+
// this.setState({accessors: new FlowmapAggregateAccessors(this.props)});
|
|
181
|
+
// }
|
|
182
|
+
|
|
183
|
+
private _getOrMakeDataProvider() {
|
|
184
|
+
const {data, dataProvider} = this.props;
|
|
185
|
+
if (isFlowmapDataProvider<L, F>(dataProvider?.dataProvider)) {
|
|
186
|
+
return dataProvider.dataProvider;
|
|
187
|
+
} else if (isFlowmapData<L, F>(data)) {
|
|
188
|
+
const dataProvider = new LocalFlowmapDataProvider<L, F>(this.props);
|
|
189
|
+
dataProvider.setFlowmapData(data);
|
|
161
190
|
return dataProvider;
|
|
162
191
|
}
|
|
163
192
|
throw new Error(
|
|
164
|
-
'
|
|
193
|
+
'FlowmapLayer: data must be a FlowmapDataProvider or FlowmapData',
|
|
165
194
|
);
|
|
166
195
|
}
|
|
167
196
|
|
|
168
197
|
private _updateDataProvider() {
|
|
169
|
-
this.setState({dataProvider: this.
|
|
198
|
+
this.setState({dataProvider: this._getOrMakeDataProvider()});
|
|
170
199
|
}
|
|
171
200
|
|
|
172
201
|
shouldUpdateState(params: Record<string, any>): boolean {
|
|
@@ -183,13 +212,8 @@ export default class FlowMapLayer<L, F> extends CompositeLayer {
|
|
|
183
212
|
}
|
|
184
213
|
|
|
185
214
|
updateState({oldProps, props, changeFlags}: Record<string, any>): void {
|
|
186
|
-
const {dataProvider, highlightedObject} = this.state || {};
|
|
187
|
-
if (!dataProvider) {
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
215
|
if (changeFlags.propsChanged) {
|
|
192
|
-
this._updateAccessors();
|
|
216
|
+
// this._updateAccessors();
|
|
193
217
|
}
|
|
194
218
|
if (changeFlags.dataChanged) {
|
|
195
219
|
this._updateDataProvider();
|
|
@@ -200,12 +224,17 @@ export default class FlowMapLayer<L, F> extends CompositeLayer {
|
|
|
200
224
|
});
|
|
201
225
|
}
|
|
202
226
|
|
|
203
|
-
if (
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
227
|
+
if (
|
|
228
|
+
changeFlags.viewportChanged ||
|
|
229
|
+
changeFlags.propsOrDataChanged // TODO can we ignore accessor props changes?
|
|
230
|
+
) {
|
|
231
|
+
const {dataProvider} = this.state || {};
|
|
232
|
+
if (dataProvider) {
|
|
233
|
+
dataProvider.setFlowmapState(this._getFlowmapState());
|
|
234
|
+
dataProvider.updateLayersData((layersData: LayersData | undefined) => {
|
|
235
|
+
this.setState({layersData});
|
|
236
|
+
}, changeFlags);
|
|
237
|
+
}
|
|
209
238
|
}
|
|
210
239
|
}
|
|
211
240
|
|
|
@@ -217,10 +246,13 @@ export default class FlowMapLayer<L, F> extends CompositeLayer {
|
|
|
217
246
|
clusteringEnabled,
|
|
218
247
|
clusteringLevel,
|
|
219
248
|
fadeEnabled,
|
|
249
|
+
fadeOpacityEnabled,
|
|
220
250
|
clusteringAuto,
|
|
221
251
|
darkMode,
|
|
222
252
|
fadeAmount,
|
|
223
253
|
colorScheme,
|
|
254
|
+
highlightColor,
|
|
255
|
+
maxTopFlowsDisplayNum,
|
|
224
256
|
} = this.props;
|
|
225
257
|
return {
|
|
226
258
|
locationTotalsEnabled,
|
|
@@ -229,40 +261,41 @@ export default class FlowMapLayer<L, F> extends CompositeLayer {
|
|
|
229
261
|
clusteringEnabled,
|
|
230
262
|
clusteringLevel,
|
|
231
263
|
fadeEnabled,
|
|
264
|
+
fadeOpacityEnabled,
|
|
232
265
|
clusteringAuto,
|
|
233
266
|
darkMode,
|
|
234
267
|
fadeAmount,
|
|
235
268
|
colorScheme,
|
|
269
|
+
highlightColor,
|
|
270
|
+
maxTopFlowsDisplayNum,
|
|
236
271
|
};
|
|
237
272
|
}
|
|
238
273
|
|
|
239
|
-
private
|
|
274
|
+
private _getFlowmapState() {
|
|
240
275
|
return {
|
|
241
|
-
viewport:
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
locationFilterMode: LocationFilterMode.ALL,
|
|
245
|
-
selectedTimeRange: undefined,
|
|
246
|
-
},
|
|
247
|
-
settingsState: this._getSettingsState(),
|
|
276
|
+
viewport: pickViewportProps(this.context.viewport),
|
|
277
|
+
filter: this.props.filter,
|
|
278
|
+
settings: this._getSettingsState(),
|
|
248
279
|
};
|
|
249
280
|
}
|
|
250
281
|
|
|
251
|
-
private async
|
|
282
|
+
private async _getFlowmapLayerPickingInfo(
|
|
252
283
|
info: Record<string, any>,
|
|
253
|
-
): Promise<
|
|
284
|
+
): Promise<FlowmapLayerPickingInfo<L, F> | undefined> {
|
|
254
285
|
const {index, sourceLayer} = info;
|
|
255
286
|
const {dataProvider, accessors} = this.state || {};
|
|
256
287
|
if (!dataProvider || !accessors) {
|
|
257
288
|
return undefined;
|
|
258
289
|
}
|
|
259
290
|
const commonInfo = {
|
|
260
|
-
|
|
291
|
+
...info,
|
|
292
|
+
picked: info.picked,
|
|
261
293
|
layer: info.layer,
|
|
262
294
|
index: info.index,
|
|
263
295
|
x: info.x,
|
|
264
296
|
y: info.y,
|
|
265
297
|
coordinate: info.coordinate,
|
|
298
|
+
event: info.event,
|
|
266
299
|
};
|
|
267
300
|
if (
|
|
268
301
|
sourceLayer instanceof FlowLinesLayer ||
|
|
@@ -280,11 +313,13 @@ export default class FlowMapLayer<L, F> extends CompositeLayer {
|
|
|
280
313
|
if (origin && dest) {
|
|
281
314
|
return {
|
|
282
315
|
...commonInfo,
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
316
|
+
object: {
|
|
317
|
+
type: PickingType.FLOW,
|
|
318
|
+
flow,
|
|
319
|
+
origin: origin,
|
|
320
|
+
dest: dest,
|
|
321
|
+
count: accessors.getFlowMagnitude(flow),
|
|
322
|
+
},
|
|
288
323
|
};
|
|
289
324
|
}
|
|
290
325
|
}
|
|
@@ -304,13 +339,14 @@ export default class FlowMapLayer<L, F> extends CompositeLayer {
|
|
|
304
339
|
);
|
|
305
340
|
return {
|
|
306
341
|
...commonInfo,
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
342
|
+
object: {
|
|
343
|
+
type: PickingType.LOCATION,
|
|
344
|
+
location,
|
|
345
|
+
id,
|
|
346
|
+
name,
|
|
347
|
+
totals,
|
|
348
|
+
circleRadius: circleRadius,
|
|
349
|
+
},
|
|
314
350
|
};
|
|
315
351
|
}
|
|
316
352
|
}
|
|
@@ -330,9 +366,25 @@ export default class FlowMapLayer<L, F> extends CompositeLayer {
|
|
|
330
366
|
) {
|
|
331
367
|
const {lineAttributes} = this.state?.layersData || {};
|
|
332
368
|
if (lineAttributes) {
|
|
369
|
+
let attrs = getFlowLineAttributesByIndex(lineAttributes, index);
|
|
370
|
+
if (this.props.fadeOpacityEnabled) {
|
|
371
|
+
attrs = {
|
|
372
|
+
...attrs,
|
|
373
|
+
attributes: {
|
|
374
|
+
...attrs.attributes,
|
|
375
|
+
getColor: {
|
|
376
|
+
...attrs.attributes.getColor,
|
|
377
|
+
value: new Uint8Array([
|
|
378
|
+
...attrs.attributes.getColor.value.slice(0, 3),
|
|
379
|
+
255, // the highlight color should be always opaque
|
|
380
|
+
]),
|
|
381
|
+
},
|
|
382
|
+
},
|
|
383
|
+
};
|
|
384
|
+
}
|
|
333
385
|
return {
|
|
334
386
|
type: HighlightType.FLOW,
|
|
335
|
-
lineAttributes:
|
|
387
|
+
lineAttributes: attrs,
|
|
336
388
|
};
|
|
337
389
|
}
|
|
338
390
|
} else if (sourceLayer instanceof FlowCirclesLayer) {
|
|
@@ -340,7 +392,7 @@ export default class FlowMapLayer<L, F> extends CompositeLayer {
|
|
|
340
392
|
if (circleAttributes) {
|
|
341
393
|
return {
|
|
342
394
|
type: HighlightType.LOCATION,
|
|
343
|
-
|
|
395
|
+
coords: getLocationCoordsByIndex(circleAttributes, index),
|
|
344
396
|
radius: getOuterCircleRadiusByIndex(circleAttributes, index),
|
|
345
397
|
};
|
|
346
398
|
}
|
|
@@ -354,9 +406,9 @@ export default class FlowMapLayer<L, F> extends CompositeLayer {
|
|
|
354
406
|
const {layersData, highlightedObject} = this.state;
|
|
355
407
|
const {circleAttributes, lineAttributes} = layersData || {};
|
|
356
408
|
if (circleAttributes && lineAttributes) {
|
|
357
|
-
const
|
|
409
|
+
const flowmapColors = getFlowmapColors(this._getSettingsState());
|
|
358
410
|
const outlineColor = colorAsRgba(
|
|
359
|
-
|
|
411
|
+
flowmapColors.outlineColor || (this.props.darkMode ? '#000' : '#fff'),
|
|
360
412
|
);
|
|
361
413
|
const commonLineLayerProps = {
|
|
362
414
|
data: lineAttributes,
|
|
@@ -395,8 +447,10 @@ export default class FlowMapLayer<L, F> extends CompositeLayer {
|
|
|
395
447
|
this.getSubLayerProps({
|
|
396
448
|
id: 'circles',
|
|
397
449
|
data: circleAttributes,
|
|
398
|
-
emptyColor:
|
|
399
|
-
|
|
450
|
+
emptyColor: this.props.darkMode
|
|
451
|
+
? [0, 0, 0, 255]
|
|
452
|
+
: [255, 255, 255, 255],
|
|
453
|
+
outlineEmptyMix: 0.4,
|
|
400
454
|
}),
|
|
401
455
|
),
|
|
402
456
|
);
|
|
@@ -409,15 +463,15 @@ export default class FlowMapLayer<L, F> extends CompositeLayer {
|
|
|
409
463
|
id: 'location-highlight',
|
|
410
464
|
data: [highlightedObject],
|
|
411
465
|
pickable: false,
|
|
466
|
+
antialiasing: true,
|
|
412
467
|
stroked: true,
|
|
413
468
|
filled: false,
|
|
414
469
|
lineWidthUnits: 'pixels',
|
|
415
470
|
getLineWidth: 2,
|
|
416
471
|
radiusUnits: 'pixels',
|
|
417
472
|
getRadius: (d: HighlightedLocationObject) => d.radius,
|
|
418
|
-
getLineColor: (
|
|
419
|
-
|
|
420
|
-
getPosition: (d: HighlightedLocationObject) => d.centroid,
|
|
473
|
+
getLineColor: colorAsRgba(this.props.highlightColor),
|
|
474
|
+
getPosition: (d: HighlightedLocationObject) => d.coords,
|
|
421
475
|
}),
|
|
422
476
|
}),
|
|
423
477
|
);
|
|
@@ -430,7 +484,7 @@ export default class FlowMapLayer<L, F> extends CompositeLayer {
|
|
|
430
484
|
data: highlightedObject.lineAttributes,
|
|
431
485
|
drawOutline: true,
|
|
432
486
|
pickable: false,
|
|
433
|
-
outlineColor: colorAsRgba(
|
|
487
|
+
outlineColor: colorAsRgba(this.props.highlightColor),
|
|
434
488
|
outlineThickness: 1,
|
|
435
489
|
}),
|
|
436
490
|
}),
|
|
@@ -445,7 +499,7 @@ export default class FlowMapLayer<L, F> extends CompositeLayer {
|
|
|
445
499
|
}
|
|
446
500
|
}
|
|
447
501
|
|
|
448
|
-
function
|
|
502
|
+
function pickViewportProps(viewport: Record<string, any>): ViewportProps {
|
|
449
503
|
const {width, height, longitude, latitude, zoom, pitch, bearing} = viewport;
|
|
450
504
|
return {
|
|
451
505
|
width,
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export {default as AnimatedFlowLinesLayer} from './AnimatedFlowLinesLayer';
|
|
2
2
|
export {default as FlowLinesLayer} from './FlowLinesLayer';
|
|
3
3
|
export {default as FlowCirclesLayer} from './FlowCirclesLayer';
|
|
4
|
-
export {default as
|
|
5
|
-
export type {
|
|
4
|
+
export {default as FlowmapLayer} from './FlowmapLayer';
|
|
5
|
+
export type {FlowmapLayerProps} from './FlowmapLayer';
|
|
6
6
|
|
|
7
7
|
export * from './types';
|
package/src/types.ts
CHANGED
|
@@ -18,34 +18,41 @@ export type DeckGLLayer = Record<string, any>;
|
|
|
18
18
|
export interface PickingInfo<T> {
|
|
19
19
|
layer: DeckGLLayer;
|
|
20
20
|
index: number;
|
|
21
|
+
picked: boolean;
|
|
21
22
|
object: T | undefined;
|
|
22
23
|
x: number;
|
|
23
24
|
y: number;
|
|
24
25
|
coordinate: [number, number];
|
|
26
|
+
event: MouseEvent | undefined;
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
export interface
|
|
28
|
-
type: PickingType.LOCATION;
|
|
29
|
+
export interface LocationPickingInfoObject<L> {
|
|
29
30
|
id: string;
|
|
31
|
+
type: PickingType.LOCATION;
|
|
32
|
+
location: L | ClusterNode;
|
|
30
33
|
name: string;
|
|
31
34
|
totals: LocationTotals;
|
|
32
35
|
circleRadius: number;
|
|
33
|
-
event: MouseEvent | undefined;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
export
|
|
38
|
+
export type LocationPickingInfo<L> = PickingInfo<LocationPickingInfoObject<L>>;
|
|
39
|
+
|
|
40
|
+
export interface FlowPickingInfoObject<L, F> {
|
|
37
41
|
type: PickingType.FLOW;
|
|
42
|
+
flow: F | AggregateFlow;
|
|
38
43
|
origin: L | ClusterNode;
|
|
39
44
|
dest: L | ClusterNode;
|
|
40
45
|
count: number;
|
|
41
46
|
}
|
|
42
47
|
|
|
48
|
+
export type FlowPickingInfo<L, F> = PickingInfo<FlowPickingInfoObject<L, F>>;
|
|
49
|
+
|
|
43
50
|
// export interface LocationAreaPickingInfo extends PickingInfo<PickingInfoData> {
|
|
44
51
|
// type: PickingType.LOCATION_AREA;
|
|
45
52
|
// object: FlowLocation;
|
|
46
53
|
// }
|
|
47
54
|
|
|
48
|
-
export type
|
|
55
|
+
export type FlowmapLayerPickingInfo<L, F> =
|
|
49
56
|
| LocationPickingInfo<L>
|
|
50
57
|
// | LocationAreaPickingInfo
|
|
51
58
|
| FlowPickingInfo<L, F>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FlowMapLayer.d.ts","sourceRoot":"","sources":["../src/FlowMapLayer.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAE7C,OAAO,EAEL,wBAAwB,EACxB,WAAW,EACX,oBAAoB,EACpB,mBAAmB,EAOnB,UAAU,EAIV,yB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