import {experimental} from 'react-map-gl'; import {MapModes} from "./actionTypes"; export default class TILESMapControls extends experimental.MapControls { constructor({type, handlePanStart, handlePanMove, handlePanEnd, handlePanMoveSpatialFilter, handleClick, handleCloseSpatialFilter}) { super(); this.mode = type; this.onPanStart = handlePanStart; this.onPanEnd = handlePanEnd; this.onPanMove = handlePanMove; this.onClick = handleClick; this.onPanMoveSpatialFilter = handlePanMoveSpatialFilter; this.onCloseSpatialFilter = handleCloseSpatialFilter; this.events = ['click', 'mousemove', 'dblclick']; } setMode(mode) { // if (this.mode !== mode) { // console.log(`map controls switching to mode: ${mode}`); // } this.mode = mode; } handleEvent(event) { if (this.mode === MapModes.DRAWINGCROSSSECTION) { if (event.type === 'panstart') { this.onPanStart(event); } else if (event.type === 'panend') { this.onPanEnd(event); } else if (event.type === 'panmove') { this.onPanMove(event); } } else if (this.mode === MapModes.DRAWINGSPATIALFILTER) { if (event.type === 'mousemove') { this.onPanMoveSpatialFilter(event); } else if (event.type === 'click') { this.onClick(event); } else if (event.type === 'dblclick') { this.onCloseSpatialFilter(event); } } else { return super.handleEvent(event); } } }