summaryrefslogtreecommitdiff
path: root/src/components/map/controls/ZoomControlComponent.js
diff options
context:
space:
mode:
authorGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-09-21 19:15:08 +0200
committerGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-09-23 10:06:05 +0200
commitd2fe45aaa1b265c0caad7e83b16f6f2adbcd4c27 (patch)
treea6332d2335f4c769bc38f3eebfb916a2a816337d /src/components/map/controls/ZoomControlComponent.js
parent4272111ce7da4293bff7d11cf08e172651e7b3b1 (diff)
Add tool panel to lower left map corner
Diffstat (limited to 'src/components/map/controls/ZoomControlComponent.js')
-rw-r--r--src/components/map/controls/ZoomControlComponent.js31
1 files changed, 31 insertions, 0 deletions
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 (
+ <span>
+ <button
+ className="btn btn-default btn-circle btn-sm mr-1"
+ title="Zoom in"
+ onClick={() => zoom(false)}
+ >
+ <span className="fa fa-plus"/>
+ </button>
+ <button
+ className="btn btn-default btn-circle btn-sm mr-1"
+ title="Zoom out"
+ onClick={() => zoom(true)}
+ >
+ <span className="fa fa-minus"/>
+ </button>
+ </span>
+ );
+};
+
+export default ZoomControlComponent;