Skip to content
Snippets Groups Projects
Commit 999a51de authored by Janne Alatalo's avatar Janne Alatalo :neutral_face:
Browse files

Add lam point hover and click handlers

parent 761766f1
No related branches found
No related tags found
No related merge requests found
...@@ -21,7 +21,9 @@ class PointMap extends Component { ...@@ -21,7 +21,9 @@ class PointMap extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { viewport }; const mouseover = null;
const clicked = null;
this.state = { viewport, mouseover, clicked };
} }
update_tooltip(visible, x, y, content) { update_tooltip(visible, x, y, content) {
...@@ -38,6 +40,36 @@ class PointMap extends Component { ...@@ -38,6 +40,36 @@ class PointMap extends Component {
}); });
} }
handleOnHover(e) {
this.setState(prevState => {
let mouseover = null;
if (e.picked) {
mouseover = e.object.get_id();
}
return { ...prevState, mouseover };
});
}
handleOnClickObject(e) {
this.setState(prevState => {
let clicked = null;
if (e.picked) {
clicked = e.object.get_id();
}
return { ...prevState, clicked };
});
return false;
}
handleOnClickMap(e) {
if (e === null) {
this.setState(prevState => {
const clicked = null;
return { ...prevState, clicked };
});
}
}
render() { render() {
const point_coords = this.props.points.toArray(); const point_coords = this.props.points.toArray();
const layers = [ const layers = [
...@@ -59,6 +91,16 @@ class PointMap extends Component { ...@@ -59,6 +91,16 @@ class PointMap extends Component {
filled: true, filled: true,
extruded: true, extruded: true,
getElevation: d => d.get_avg_traffic_vol() * 20, getElevation: d => d.get_avg_traffic_vol() * 20,
getLineColor: d => {
if (this.state.mouseover === d.get_id()) {
return [255, 0, 0];
}
return d.get_color();
},
wireframe: true,
pickable: true,
onClick: e => this.handleOnClickObject(e),
onHover: e => this.handleOnHover(e),
}) })
]; ];
...@@ -70,6 +112,7 @@ class PointMap extends Component { ...@@ -70,6 +112,7 @@ class PointMap extends Component {
layers={layers} layers={layers}
controller={MapController} controller={MapController}
onViewportChange={v => this.setState({viewport: v})} onViewportChange={v => this.setState({viewport: v})}
onLayerClick={e => this.handleOnClickMap(e)}
> >
<StaticMap <StaticMap
{...this.props.mapSize} {...this.props.mapSize}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment