Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

initial boilerplate and button setup

Jason Kent0c78a6f177f4
diff --git a/web/css/button.css b/web/css/button.css
index 8a42e1efb..f3f20c718 100644
--- a/web/css/button.css
+++ b/web/css/button.css
@@ -45,3 +45,18 @@
color: #eee;
cursor: not-allowed;
}
+
+.wv-measure-button {
+ position: absolute;
+ bottom: 180px;
+ right: 10px;
+ padding: 6px 10px;
+}
+.modal-dialog.toolbar-modal.measure-tool-modal {
+ top: unset;
+ right: 70px;
+ bottom: 157px;
+ & .modal-body {
+ padding: 0;
+ }
+}
diff --git a/web/css/toolbar.css b/web/css/toolbar.css
index 3cdbc5ef9..3e583629d 100644
--- a/web/css/toolbar.css
+++ b/web/css/toolbar.css
@@ -6,7 +6,7 @@
border-radius: 0;
}
-.wv-toolbar .wv-toolbar-button {
+.wv-toolbar-button {
font-size: 14.3px;
display: inline-block;
margin: 0 0 0 4px;
@@ -14,21 +14,18 @@
border: 1px solid #333;
padding: 5.72px 14.3px;
border-radius: 5px;
-}
-
-.wv-toolbar-button:focus {
- box-shadow: none;
- -webkit-box-shadow: none;
-}
-
-.wv-toolbar .wv-toolbar-button:hover {
- background-color: #fff;
- color: #1a1a1a;
-}
-
-.wv-toolbar .wv-toolbar-button.disabled:hover {
- background-color: rgba(40, 40, 40, 0.85);
- color: #eee;
+ &:focus {
+ box-shadow: none;
+ -webkit-box-shadow: none;
+ }
+ &:hover {
+ background-color: #eee;
+ color: #1a1a1a;
+ }
+ &.disabled:hover {
+ background-color: rgba(40, 40, 40, 0.85);
+ color: #eee;
+ }
}
.wv-toolbar .btn.disabled {
diff --git a/web/js/app.js b/web/js/app.js
index 5c69ea991..6183e2e85 100644
--- a/web/js/app.js
+++ b/web/js/app.js
@@ -14,6 +14,7 @@ import Modal from './containers/modal';
// Other
import Brand from './brand';
+import MeasureButton from './components/measure-tool/measure-button';
// actions
import { calculateResponsiveState } from 'redux-responsive';
@@ -113,6 +114,7 @@ class App extends React.Component {
<div id="wv-animation-widet-case">
{isAnimationWidgetActive ? <AnimationWidget /> : null}
</div>
+ <MeasureButton />
<OlCoordinates mouseEvents={this.props.mapMouseEvents} />
<Modal />
<ErrorBoundary>
diff --git a/web/js/components/measure-tool/measure-button.js b/web/js/components/measure-tool/measure-button.js
new file mode 100644
index 000000000..18fe42758
--- /dev/null
+++ b/web/js/components/measure-tool/measure-button.js
@@ -0,0 +1,46 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import { connect } from 'react-redux';
+import { Button } from 'reactstrap';
+import MeasureMenu from './measure-menu';
+import { openCustomContent } from '../../modules/modal/actions';
+
+const MEASURE_MENU_PROPS = {
+ headerText: null,
+ type: 'toolbar',
+ modalClassName: 'measure-tool-modal toolbar-modal',
+ backdrop: false,
+ bodyComponent: MeasureMenu,
+ wrapClassName: 'toolbar_modal_outer'
+};
+
+class MeasureButton extends React.Component {
+ render() {
+ const { openModal } = this.props;
+ return (
+ <Button
+ id="wv-measure-button"
+ className="wv-measure-button wv-toolbar-button"
+ title="Measure distances &amp; areas"
+ onClick={() => openModal('MEASURE_MENU', MEASURE_MENU_PROPS)}
+ >
+ <i className="fas fa-ruler fa-2x"></i>{' '}
+ </Button>
+ );
+ }
+}
+
+const mapDispatchToProps = dispatch => ({
+ openModal: (key, customParams) => {
+ dispatch(openCustomContent(key, customParams));
+ }
+});
+
+export default connect(
+ null,
+ mapDispatchToProps
+)(MeasureButton);
+
+MeasureButton.propTypes = {
+ openModal: PropTypes.func
+};
diff --git a/web/js/components/measure-tool/measure-menu.js b/web/js/components/measure-tool/measure-menu.js
new file mode 100644
index 000000000..33d2fc253
--- /dev/null
+++ b/web/js/components/measure-tool/measure-menu.js
@@ -0,0 +1,68 @@
+import React, { Component } from 'react';
+import PropTypes from 'prop-types';
+import { connect } from 'react-redux';
+import { onToggle } from '../../modules/modal/actions';
+import { measureDistance, measureArea, clearMeasurements } from '../../modules/measure/actions';
+import IconList from '../util/list';
+// import googleTagManager from 'googleTagManager';
+
+const OPTIONS_ARRAY = [
+ {
+ text: 'Measure distance',
+ iconClass: 'ui-icon icon-large fa - fa-fw',
+ id: 'measure-distance-button',
+ key: measureDistance
+ },
+ {
+ text: 'Measure area',
+ iconClass: 'ui-icon icon-large fa - fa-fw',
+ id: 'measure-area-button',
+ key: measureArea
+ },
+ {
+ text: 'Clear Measurements',
+ iconClass: 'ui-icon icon-large fa - fa-fw',
+ id: 'clear-measurements-button',
+ key: clearMeasurements
+ }
+];
+
+class MeasureMenu extends Component {
+ dispatchAction(action) {
+ const { dispatchAction, onCloseModal } = this.props;
+ dispatchAction(action);
+ onCloseModal();
+ // googleTagManager.pushEvent({
+ // event: 'measure_tool'
+ // });
+ }
+
+ render() {
+ return (
+ <IconList
+ list={OPTIONS_ARRAY}
+ onClick={this.dispatchAction.bind(this)}
+ size="small"
+ />
+ );
+ }
+}
+
+const mapDispatchToProps = (dispatch, ownProps) => ({
+ dispatchAction: (action) => {
+ dispatch(action());
+ },
+ onCloseModal: () => {
+ dispatch(onToggle());
+ }
+});
+
+export default connect(
+ null,
+ mapDispatchToProps
+)(MeasureMenu);
+
+MeasureMenu.propTypes = {
+ dispatchAction: PropTypes.func,
+ onCloseModal: PropTypes.func
+};
diff --git a/web/js/components/toolbar/toolbar.js b/web/js/components/toolbar/toolbar.js
deleted file mode 100644
index d28c6d74f..000000000
--- a/web/js/components/toolbar/toolbar.js
+++ /dev/null
@@ -1,63 +0,0 @@
-import React from 'react';
-// import Share from './share/index.js';
-// import Projection from './projection/index.js';
-// import Snapshot from './snapshot/index.js';
-// import Info from './info/index.js'
-
-class Toolbar extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- modalShare: false,
- modalProjection: false,
- modalSnapshot: false,
- modalInfo: false
- };
-
- this.toggleModalShare = this.toggleModalShare.bind(this);
- this.toggleModalProjection = this.toggleModalProjection.bind(this);
- this.toggleModalSnapshot = this.toggleModalSnapshot.bind(this);
- this.toggleModalInfo = this.toggleModalInfo.bind(this);
- }
-
- toggleModalShare(e) {
- e.preventDefault();
- this.setState({
- modalShare: !this.state.modalShare
- });
- }
-
- toggleModalProjection(e) {
- e.preventDefault();
- this.setState({
- modalProjection: !this.state.modalProjection
- });
- }
-
- toggleModalSnapshot(e) {
- e.preventDefault();
- this.setState({
- modalSnapshot: !this.state.modalSnapshot
- });
- }
-
- toggleModalInfo(e) {
- e.preventDefault();
- this.setState({
- modalInfo: !this.state.modalInfo
- });
- }
-
- render() {
- return (
- <ul id="wv-toolbar" className="wv-toolbar">
- <li id="wv-link-button" className="wv-toolbar-button"></li>
- <li id="wv-proj-button" className="wv-toolbar-button"></li>
- <li id="wv-image-button" className="wv-toolbar-button"></li>
- <li id="wv-info-button" className="wv-toolbar-button wv-status-hide"></li>
- </ul>
- );
- }
-}
-
-export default Toolbar;
diff --git a/web/js/map/ui.js b/web/js/map/ui.js
index 88160cabe..a81719b0f 100644
--- a/web/js/map/ui.js
+++ b/web/js/map/ui.js
@@ -1,4 +1,3 @@
-
import lodashFindIndex from 'lodash/findIndex';
import lodashEach from 'lodash/each';
import lodashForOwn from 'lodash/forOwn';
@@ -38,6 +37,7 @@ import * as layerConstants from '../modules/layers/constants';
import * as compareConstants from '../modules/compare/constants';
import * as paletteConstants from '../modules/palettes/constants';
import * as vectorStyleConstants from '../modules/vector-styles/constants';
+import * as measureConstants from '../modules/measure/constants';
import { setStyleFunction } from '../modules/vector-styles/selectors';
import {
getLayers,
@@ -133,7 +133,15 @@ export function mapui(models, config, store, ui) {
case CALCULATE_RESPONSIVE_STATE:
return onResize();
case SELECT_DATE:
- updateDate();
+ return updateDate();
+ case measureConstants.MEASURE_DISTANCE:
+ console.log('distance!');
+ return;
+ case measureConstants.MEASURE_AREA:
+ console.log('area!');
+ return;
+ case measureConstants.CLEAR_MEASUREMENTS:
+ console.log('clear!');
}
};
/*
diff --git a/web/js/modules/measure/actions.js b/web/js/modules/measure/actions.js
new file mode 100644
index 000000000..810e83909
--- /dev/null
+++ b/web/js/modules/measure/actions.js
@@ -0,0 +1,21 @@
+import {
+ MEASURE_DISTANCE,
+ MEASURE_AREA,
+ CLEAR_MEASUREMENTS
+} from './constants';
+
+export function measureDistance() {
+ return {
+ type: MEASURE_DISTANCE
+ };
+}
+export function measureArea() {
+ return {
+ type: MEASURE_AREA
+ };
+}
+export function clearMeasurements() {
+ return {
+ type: CLEAR_MEASUREMENTS
+ };
+}
diff --git a/web/js/modules/measure/constants.js b/web/js/modules/measure/constants.js
new file mode 100644
index 000000000..9b961e332
--- /dev/null
+++ b/web/js/modules/measure/constants.js
@@ -0,0 +1,3 @@
+export const MEASURE_DISTANCE = 'MAP/MEASURE_DISTANCE';
+export const MEASURE_AREA = 'MAP/MEASURE_AREA';
+export const CLEAR_MEASUREMENTS = 'MAP/MEASURE_AREA';
diff --git a/web/js/modules/measure/reducers.js b/web/js/modules/measure/reducers.js
new file mode 100644
index 000000000..8921fb2a0
--- /dev/null
+++ b/web/js/modules/measure/reducers.js
@@ -0,0 +1,28 @@
+import { assign as lodashAssign } from 'lodash';
+import {
+ MEASURE_DISTANCE,
+ MEASURE_AREA,
+ CLEAR_MEASUREMENTS
+} from './constants';
+
+const INITIAL_STATE = {
+ distanceSketches: [],
+ areaSketches: []
+};
+
+export default function measureReducer(state = INITIAL_STATE, action) {
+ switch (action.type) {
+ case MEASURE_DISTANCE:
+ return lodashAssign({}, state, {
+ distanceSketches: action.sketches
+ });
+ case MEASURE_AREA:
+ return lodashAssign({}, state, {
+ areaSketches: action.sketches
+ });
+ case CLEAR_MEASUREMENTS:
+ return lodashAssign({}, state, INITIAL_STATE);
+ default:
+ return state;
+ }
+}