-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
layer-info.js
45 lines (42 loc) · 1.08 KB
/
layer-info.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
import React, {PureComponent} from 'react';
export default class LayerInfo extends PureComponent {
_infoToString(info) {
const object = info.feature || info.object;
if (!object) {
return 'None';
}
const props = object.properties || object;
return JSON.stringify(props);
}
render() {
const {hovered, clicked, queried} = this.props;
return (
<div id="layer-info">
{hovered &&
hovered.object && (
<div>
<h4>Hover</h4>
<span>
Layer: {hovered.layer.id} Object: {this._infoToString(hovered)}
</span>
</div>
)}
{clicked &&
clicked.object && (
<div>
<h4>Click</h4>
<span>
Layer: {clicked.layer.id} Object: {this._infoToString(clicked)}
</span>
</div>
)}
{queried && (
<div>
<h4>Pick Result</h4>
<span>{queried.length} objects found (see console)</span>
</div>
)}
</div>
);
}
}