-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
layer-info.js
43 lines (40 loc) · 1.02 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
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 && (
<div>
<h4>Hover</h4>
<span>
Layer: {hovered.layer.id} Object: {this._infoToString(hovered)}
</span>
</div>
)}
{clicked && (
<div>
<h4>Click</h4>
<span>
Layer: {clicked.layer.id} Object: {this._infoToString(clicked)}
</span>
</div>
)}
{queried && (
<div>
<h4>Query Visible Objects</h4>
<span>{queried.length} visible objects found (see console)</span>
</div>
)}
</div>
);
}
}