Interactive interface for browsing global, full-resolution satellite imagery
add function docs, tweak styles, add icons for menu buttons
Jason Kent4f954be2b134
diff --git a/web/css/map.css b/web/css/map.cssindex 15f0c6335..6a08b71ca 100644--- a/web/css/map.css+++ b/web/css/map.css@@ -94,7 +94,7 @@.wv-map-scale-metric {position: absolute;z-index: 10;- right: 80px;+ right: 75px;color: #fff;background-color: rgba(40, 40, 40, 0.85);text-shadow: -1px -1px 0 #000,diff --git a/web/css/measure.css b/web/css/measure.cssindex 54e8040d5..ab42c4197 100644--- a/web/css/measure.css+++ b/web/css/measure.css@@ -6,25 +6,27 @@}.modal-dialog.toolbar-modal.measure-tool-modal {top: unset;- right: 70px;- bottom: 157px;+ right: 10px;+ bottom: 151px;& .modal-body {padding: 0;}}.measure-unit-toggle {- border-bottom: 1px solid #ccc;- padding: 5px 5px 5px 27px;+ border-bottom: 1px solid rgba(255, 255, 255, 0.25);+ padding: 6px 5px 6px 27px;& .custom-control-input:checked ~ .custom-control-label::before {border-color: #fff;}& .custom-control-label {margin-left: 34px;&::before {- background-color: #0a0;+ background-color: #007bff;+ top: 1px;}&::after {+ top: 3px;background-color: #fff;}}@@ -37,11 +39,11 @@border-radius: 4px;color: #fff;padding: 6px 10px;- opacity: 0.9;white-space: nowrap;+ box-shadow: 3px 3px 6px rgba(0, 0, 0, 0.75);+ border: 1px solid rgba(255, 255, 255, 0.5);}.tooltip-active {- opacity: 0.75;font-weight: 500;font-size: 16px;}@@ -50,14 +52,11 @@font-size: 16px;color: #fff;text-shadow: 1px 1px 1px #000;- opacity: 0.9;- background-color: #d54e21;- border: 1px solid rgba(255, 255, 255, 0.5);- box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);+ background-color: #000;}.tooltip-active::before,.tooltip-static::before {- border-top: 6px solid rgba(0, 0, 0, 0.5);+ border-top: 6px solid rgba(0, 0, 0, 1);border-right: 6px solid transparent;border-left: 6px solid transparent;content: "";@@ -67,5 +66,5 @@left: 50%;}.tooltip-static::before {- border-top-color: #d54e21;+ border-top-color: #000;}diff --git a/web/js/components/measure-tool/measure-menu.js b/web/js/components/measure-tool/measure-menu.jsindex 159e2ab66..5d2fe4234 100644--- a/web/js/components/measure-tool/measure-menu.js+++ b/web/js/components/measure-tool/measure-menu.js@@ -8,19 +8,19 @@ import IconList from '../util/list';const OPTIONS_ARRAY = [{text: 'Measure distance',- iconClass: 'ui-icon icon-large fa - fa-fw',+ iconClass: 'ui-icon icon-large fa fa-ruler fa-fw',id: 'measure-distance-button',key: 'measure-distance'},{text: 'Measure area',- iconClass: 'ui-icon icon-large fa - fa-fw',+ iconClass: 'ui-icon icon-large fa fa-ruler-combined fa-fw',id: 'measure-area-button',key: 'measure-area'},{- text: 'Clear Measurements',- iconClass: 'ui-icon icon-large fa - fa-fw',+ text: 'Remove Measurements',+ iconClass: 'ui-icon icon-large fa fa-trash fa-fw',id: 'clear-measurements-button',key: 'measure-clear'}diff --git a/web/js/map/measure/measure.js b/web/js/map/measure/measure.jsindex 97825186c..babe86661 100644--- a/web/js/map/measure/measure.js+++ b/web/js/map/measure/measure.js@@ -29,6 +29,55 @@ export function measure (map) {const source = new VectorSource();const projection = map.getView().getProjection().getCode();const referenceProjection = 'EPSG:4326';+ const areaBgFill = new Fill({+ color: 'rgba(213, 78, 33, 0.1)'+ });+ const solidBlackLineStroke = new Stroke({+ color: 'rgba(0, 0, 0, 1)',+ lineJoin: 'round',+ width: 5+ });+ // const solidOrange = 'rgba(255, 100, 6, 1)';+ const vectorStyles = [+ new Style({+ fill: areaBgFill,+ stroke: solidBlackLineStroke,+ geometry: styleGeometryFn+ }),+ new Style({+ stroke: new Stroke({+ color: '#fff',+ lineJoin: 'round',+ width: 2+ }),+ geometry: styleGeometryFn+ })+ ];+ const drawStyles = [+ new Style({+ fill: areaBgFill,+ stroke: solidBlackLineStroke,+ geometry: styleGeometryFn+ }),+ new Style({+ stroke: new Stroke({+ color: '#fff',+ lineDash: [10, 20],+ lineJoin: 'round',+ width: 2+ }),+ image: new CircleStyle({+ radius: 7,+ stroke: new Stroke({+ color: 'rgba(0, 0, 0, 0.7)'+ }),+ fill: new Fill({+ color: 'rgba(255, 255, 255, 0.3)'+ })+ }),+ geometry: styleGeometryFn+ })+ ];function pointerMoveHandler (evt) {if (evt.dragging) {@@ -99,57 +148,14 @@ export function measure (map) {map.removeOverlay(helpTooltip);map.removeInteraction(draw);unByKey(drawChangeListener);-- console.log(allGeometries);- console.log(allMeasureTooltips);};- function getVectorLayer () {- return new VectorLayer({- source,- style: new Style({- fill: new Fill({- color: 'rgba(213, 78, 33, 0.1)'- }),- stroke: new Stroke({- color: 'rgba(255, 100, 6, 1)',- lineJoin: 'round',- width: 3- }),- geometry: styleGeometryFn- })- });- }-- function getDraw (type) {- return new Draw({- source,- type,- style: new Style({- fill: new Fill({- color: 'rgba(213, 78, 33, 0.1)'- }),- stroke: new Stroke({- color: 'rgba(255, 100, 6, 1)',- lineDash: [10, 20],- lineJoin: 'round',- width: 4- }),- image: new CircleStyle({- radius: 7,- stroke: new Stroke({- color: 'rgba(0, 0, 0, 0.7)'- }),- fill: new Fill({- color: 'rgba(255, 255, 255, 0.3)'- })- }),- geometry: styleGeometryFn- })- });- };-- const styleGeometryFn = (feature) => {+ /**+ * Call the appropriate transform function to add great circle arcs to+ * lines and polygon edges. Otherwise pass through unaffected.+ * @param {*} feature+ */+ function styleGeometryFn (feature) {const geometry = feature.getGeometry();if (geometry instanceof LineString) {return transformLineStringArc(geometry);@@ -161,8 +167,9 @@ export function measure (map) {};/**- *- * @param {*} feature+ * Transforms a LineString of two points to a MultiLineString of multiple points+ * applying a great circle arc transformation+ * @param {*} geom - the geometry object to apply great circle arc transformation to*/function transformLineStringArc (geom) {const coords = [];@@ -185,6 +192,11 @@ export function measure (map) {return new MultiLineString(coords).transform(referenceProjection, projection);};+ /**+ * Transforms a Polygon to one with addiitonal points on each edge to account for+ * great circle arc+ * @param {*} geom - the geometry object to apply great circle arc transformation to+ */function transformPolygonArc (geom) {let coords = [];const transformedGeom = geom.clone().transform(projection, referenceProjection);@@ -208,26 +220,11 @@ export function measure (map) {};/**- * Add the map interactionn- * @param {String} measureType- */- function addInteraction(measureType) {- const type = (measureType === 'area' ? 'Polygon' : 'LineString');- if (draw) {- map.removeInteraction(draw);- }- draw = getDraw(type);- if (!vector) {- vector = getVectorLayer();- vector.setMap(map);- }- map.addInteraction(draw);- createMeasureTooltip();- createHelpTooltip();- draw.on('drawstart', drawStartCallback, this);- draw.on('drawend', drawEndCallback, this);- }-+ * Set the innerHTML of the given tooltip element to the formatted length/area+ * measruement of the given geometry+ * @param {*} geometry+ * @param {*} element+ */function setMeasurement(geometry, element) {let measurement;if (geometry instanceof Polygon) {@@ -239,6 +236,12 @@ export function measure (map) {element.innerHTML = measurement;}+ /**+ * Convert and format raw measurements to two decimal points+ * @param {*} measurement+ * @param {*} factor+ * @return {String} - The measurement, converted based on factor and locale+ */const roundAndLocale = (measurement, factor) => {factor = factor || 1;return (Math.round(measurement / factor * 100) / 100).toLocaleString();@@ -246,7 +249,8 @@ export function measure (map) {/***- * @param {*} polygon+ * @param {*} line+ * @return {String} - The formatted distance measurement*/const formatLength = (line) => {const metricLength = getLength(line, { projection });@@ -266,6 +270,7 @@ export function measure (map) {/**** @param {*} polygon+ * @return {String} - The formatted area measurement*/const formatArea = (polygon) => {const metricArea = getArea(polygon, { projection });@@ -282,11 +287,32 @@ export function measure (map) {}};+ /**+ * Initiate a measurement interaction of the given measureType ('distance' or 'area')+ * @param {String} measureType+ */self.initMeasurement = (measureType) => {+ const type = (measureType === 'area' ? 'Polygon' : 'LineString');map.on('pointermove', pointerMoveHandler);- addInteraction(measureType);+ if (draw) {+ map.removeInteraction(draw);+ }+ draw = new Draw({ source, type, style: drawStyles });+ if (!vector) {+ vector = new VectorLayer({ source, style: vectorStyles });+ vector.setMap(map);+ }+ map.addInteraction(draw);+ createMeasureTooltip();+ createHelpTooltip();+ draw.on('drawstart', drawStartCallback, this);+ draw.on('drawend', drawEndCallback, this);};+ /**+ * Convert unit of measurement on all existing measurments and those created after+ * @param {String} unit - Unit of measurement: 'km' or 'mi'+ */self.toggleUnits = (unit) => {unitOfMeasure = unit;for (const id in allMeasureTooltips) {@@ -296,6 +322,9 @@ export function measure (map) {}};+ /**+ * Clear all existing measurements on the associated map+ */self.clearMeasurements = () => {for (const id in allMeasureTooltips) {map.removeOverlay(allMeasureTooltips[id]);