From d2fe45aaa1b265c0caad7e83b16f6f2adbcd4c27 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Thu, 21 Sep 2017 19:15:08 +0200 Subject: Add tool panel to lower left map corner --- .../map/controls/ZoomControlComponent.js | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/components/map/controls/ZoomControlComponent.js (limited to 'src/components/map/controls/ZoomControlComponent.js') diff --git a/src/components/map/controls/ZoomControlComponent.js b/src/components/map/controls/ZoomControlComponent.js new file mode 100644 index 00000000..c5628d16 --- /dev/null +++ b/src/components/map/controls/ZoomControlComponent.js @@ -0,0 +1,31 @@ +import React from "react"; +import {MAP_MAX_SCALE, MAP_MIN_SCALE, MAP_SCALE_PER_EVENT} from "../MapConstants"; + +const ZoomControlComponent = ({mapScale, setMapScale}) => { + const zoom = (out) => { + const newScale = out ? mapScale / MAP_SCALE_PER_EVENT : mapScale * MAP_SCALE_PER_EVENT; + const boundedScale = Math.min(Math.max(MAP_MIN_SCALE, newScale), MAP_MAX_SCALE); + setMapScale(boundedScale); + }; + + return ( + + + + + ); +}; + +export default ZoomControlComponent; -- cgit v1.2.3