-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathindex.js
76 lines (66 loc) · 1.67 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* @Author: hijiangtao ([email protected])
* @Date: 2019-01-24 19:25:14
* @Desc: Icon Layer with cluster option
* @Last Modified time: 2019-01-24 19:25:14
*/
import {IconLayer, CompositeLayer} from 'deck.gl';
import IconClusterLayer from './cluster';
import { iconMapping as DEFAULT_ICONMAPPING } from './icon-mapping';
class IconMap extends CompositeLayer {
renderLayers() {
const {
data,
iconMapping,
iconAtlas,
showCluster,
viewState,
getPosition,
sizeScale,
wrapLongitude,
pickable,
positionKeyName,
...otherProps
} = this.props;
const layerProps = {
...otherProps,
data,
getPosition,
sizeScale,
wrapLongitude,
pickable,
positionKeyName,
iconAtlas,
iconMapping,
};
const size = viewState ? Math.min(1.5**(viewState.zoom - 10), 1) : 0.4;
const layer = showCluster
? new IconClusterLayer({
...layerProps,
id: `${this.id}-ic-child`,
})
: new IconLayer({
...layerProps,
id: `${this.id}-i-child`,
getIcon: () => 'marker',
getSize: size,
});
return [layer];
}
}
IconMap.layerName = 'MixedIconMap';
IconMap.defaultProps = {
...IconLayer.defaultProps,
showCluster: true,
iconAtlas: 'https://raw.githubusercontent.com/uber/deck.gl/17b1b9a5c7acd4503f85b81a68560b241a0f319e/examples/website/icon/data/location-icon-atlas.png',
iconMapping: DEFAULT_ICONMAPPING,
pickable: true,
wrapLongitude: true,
getPosition: d => d.coordinates,
positionKeyName: 'coordinates',
sizeScale: {
type: 'number',
value: 60,
},
};
export default IconMap;