Commit 7f980fc4 authored by alain's avatar alain 🐙
Browse files

revert different take on map hover/tooltip

parent 59d55e29
......@@ -3,7 +3,6 @@ import { connect } from 'react-redux'
import memoize from "memoize-one";
import DeckGL from '@deck.gl/react';
import WebMercatorViewport from 'viewport-mercator-project'
import StationLayer from "./StationLayer"
import StationTooltip from "./StationTooltip"
......@@ -30,13 +29,10 @@ class DeckLayers extends React.Component {
renderTooltip() {
const { hover, hoverContent } = this.state || {}
const { hover, hoverContent, mousePosition } = this.state || {}
if(hover) {
const webMercatorViewport = new WebMercatorViewport(this.props.viewport)
const pixelCoords = webMercatorViewport.project(hover.coordinates)
return <Tooltip position={pixelCoords} content={hoverContent} />
return <Tooltip position={mousePosition} content={hoverContent} />
}
}
......@@ -91,6 +87,7 @@ class DeckLayers extends React.Component {
pickable: true,
extruded: true,
onHover: e => this.setState({
mousePosition: [e.x, e.y],
hover: e.object,
hoverContent: <StationTooltip d={e.object} label={layerDefinition.label} unit={unit.label} />
}),
......@@ -123,6 +120,7 @@ class DeckLayers extends React.Component {
getPosition: d => d.coordinates,
//getColor: d => layerDefinition.getColor(d[layerDefinition.getColorKey]),
onHover: e => this.setState({
mousePosition: [e.x, e.y],
hover: e.object,
hoverContent: <IconTooltip d={e.object} keys={layerDefinition.keysTooltip} />
}),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment