Interactive interface for browsing global, full-resolution satellite imagery
improve styles, include projection with distance/area calculation to get accurate measurements
Jason Kent2fb3a2c0f194
diff --git a/web/css/map.css b/web/css/map.cssindex 0bdd483c2..15f0c6335 100644--- a/web/css/map.css+++ b/web/css/map.css@@ -90,11 +90,11 @@}}-.wv-map-scale-imperial {+.wv-map-scale-imperial,+.wv-map-scale-metric {position: absolute;z-index: 10;- right: 10px;- bottom: 130px;+ right: 80px;color: #fff;background-color: rgba(40, 40, 40, 0.85);text-shadow: -1px -1px 0 #000,@@ -102,26 +102,17 @@-1px 1px 0 #000,1px 1px 0 #000;padding: 3px;- border-top: 2px solid #fff;border-left: 2px solid #fff;border-right: 2px solid #fff;}+.wv-map-scale-imperial {+ bottom: 130px;+ border-top: 2px solid #fff;+}.wv-map-scale-metric {- position: absolute;- z-index: 10;- right: 10px;bottom: 149px;- color: #fff;- background-color: rgba(40, 40, 40, 0.85);- text-shadow: -1px -1px 0 #000,- 1px -1px 0 #000,- -1px 1px 0 #000,- 1px 1px 0 #000;- padding: 3px;border-bottom: 2px solid #fff;- border-left: 2px solid #fff;- border-right: 2px solid #fff;}.ol-mouse-position {diff --git a/web/css/measure.css b/web/css/measure.cssindex ffe1c26ce..54e8040d5 100644--- a/web/css/measure.css+++ b/web/css/measure.css@@ -1,6 +1,6 @@.wv-measure-button {position: absolute;- bottom: 180px;+ bottom: 128px;right: 10px;padding: 6px 10px;}@@ -16,34 +16,46 @@.measure-unit-toggle {border-bottom: 1px solid #ccc;padding: 5px 5px 5px 27px;+ & .custom-control-input:checked ~ .custom-control-label::before {+ border-color: #fff;+ }& .custom-control-label {margin-left: 34px;+ &::before {+ background-color: #0a0;+ }+ &::after {+ background-color: #fff;+ }}}/* TODO selector name is too generic */-.tooltip {+.tooltip-measure {position: relative;- background: rgba(0, 0, 0, 0.5);+ background: #000;border-radius: 4px;color: #fff;- padding: 4px 8px;- opacity: 0.75;+ padding: 6px 10px;+ opacity: 0.9;white-space: nowrap;}-.tooltip-measure {- opacity: 1;- font-weight: 600;+.tooltip-active {+ opacity: 0.75;+ font-weight: 500;+ font-size: 16px;}.tooltip-static {- background-color: #fc3;- color: #000;- border: 1px solid #fff;- font-weight: 700;+ font-weight: 500;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);}-.tooltip-measure::before,+.tooltip-active::before,.tooltip-static::before {border-top: 6px solid rgba(0, 0, 0, 0.5);border-right: 6px solid transparent;@@ -55,5 +67,5 @@left: 50%;}.tooltip-static::before {- border-top-color: #fc3;+ border-top-color: #d54e21;}diff --git a/web/js/map/measure/measure.js b/web/js/map/measure/measure.jsindex df27043c8..c92a20381 100644--- a/web/js/map/measure/measure.js+++ b/web/js/map/measure/measure.js@@ -7,7 +7,7 @@ import { Vector as VectorLayer } from 'ol/layer';import { Vector as VectorSource } from 'ol/source';import { Circle as CircleStyle, Fill, Stroke, Style } from 'ol/style';-export function measure (map) {+export function measure (map, projection) {const self = {};let draw;let sketch;@@ -17,8 +17,6 @@ export function measure (map) {let measureTooltip;let allMeasureTooltips = [];let drawChangeListener;- const continuePolygonMsg = 'Click to continue drawing <br/> Double-click to complete.';- const continueLineMsg = 'Click to continue drawing <br/> Double-click to complete.';const source = new VectorSource();const vector = getVectorLayer(source);@@ -29,16 +27,10 @@ export function measure (map) {if (evt.dragging) {return;}- let helpMsg = 'Click to start drawing';+ const helpMsg = !sketch+ ? 'Click to start drawing.'+ : 'Click to continue drawing. <br/> Double-click to complete.';- if (sketch) {- const geom = (sketch.getGeometry());- if (geom instanceof Polygon) {- helpMsg = continuePolygonMsg;- } else if (geom instanceof LineString) {- helpMsg = continueLineMsg;- }- }helpTooltipElement.innerHTML = helpMsg;helpTooltip.setPosition(evt.coordinate);helpTooltipElement.classList.remove('hidden');@@ -49,10 +41,10 @@ export function measure (map) {helpTooltipElement.parentNode.removeChild(helpTooltipElement);}helpTooltipElement = document.createElement('div');- helpTooltipElement.className = 'tooltip hidden';+ helpTooltipElement.className = 'tooltip-measure hidden';helpTooltip = new Overlay({element: helpTooltipElement,- offset: [15, 0],+ offset: [15, 15],positioning: 'center-left'});map.addOverlay(helpTooltip);@@ -63,7 +55,7 @@ export function measure (map) {measureTooltipElement.parentNode.removeChild(measureTooltipElement);}measureTooltipElement = document.createElement('div');- measureTooltipElement.className = 'tooltip tooltip-measure';+ measureTooltipElement.className = 'tooltip-measure tooltip-active';measureTooltip = new Overlay({element: measureTooltipElement,offset: [0, -15],@@ -80,10 +72,10 @@ export function measure (map) {const geom = evt.target;let output;if (geom instanceof Polygon) {- output = formatArea(geom);+ output = formatArea(geom, projection);tooltipCoord = geom.getInteriorPoint().getCoordinates();} else if (geom instanceof LineString) {- output = formatLength(geom);+ output = formatLength(geom, projection);tooltipCoord = geom.getLastCoordinate();}measureTooltipElement.innerHTML = output;@@ -92,7 +84,7 @@ export function measure (map) {};function drawEndCallback () {- measureTooltipElement.className = 'tooltip tooltip-static';+ measureTooltipElement.className = 'tooltip-measure tooltip-static';measureTooltip.setOffset([0, -7]);sketch = null;measureTooltipElement = null;@@ -135,21 +127,21 @@ export function measure (map) {return self;}-const formatLength = (line) => {- const length = getLength(line);+const formatLength = (line, projection) => {+ const length = getLength(line, { projection });if (length > 100) {- return (Math.round(length / 1000 * 100) / 100) + ' ' + 'km';+ return (Math.round(length / 1000 * 100) / 100).toLocaleString() + ' ' + 'km';} else {- return (Math.round(length * 100) / 100) + ' ' + 'm';+ return (Math.round(length * 100) / 100).toLocaleString() + ' ' + 'm';}};-const formatArea = (polygon) => {- const area = getArea(polygon);+const formatArea = (polygon, projection) => {+ const area = getArea(polygon, { projection });if (area > 10000) {- return `${(Math.round(area / 1000000 * 100) / 100)} km<sup>2</sup>`;+ return `${(Math.round(area / 1000000 * 100) / 100).toLocaleString()} km<sup>2</sup>`;} else {- return `${Math.round(area * 100) / 100} m<sup>2</sup>`;+ return `${(Math.round(area * 100) / 100).toLocaleString()} m<sup>2</sup>`;}};@@ -158,17 +150,12 @@ const getVectorLayer = (source) => {source,style: new Style({fill: new Fill({- color: 'rgba(255, 255, 255, 0.2)'+ color: 'rgba(213, 78, 33, 0.1)'}),stroke: new Stroke({- color: '#ffcc33',- width: 2- }),- image: new CircleStyle({- radius: 7,- fill: new Fill({- color: '#ffcc33'- })+ color: '#d54e21',+ lineJoin: 'round',+ width: 3})})});@@ -180,15 +167,16 @@ const getDraw = (source, type) => {type,style: new Style({fill: new Fill({- color: 'rgba(255, 255, 255, 0.2)'+ color: 'rgba(213, 78, 33, 0.1)'}),stroke: new Stroke({- color: 'rgba(0, 0, 0, 0.5)',+ color: 'rgba(213, 78, 33, 1)',lineDash: [10, 10],- width: 2+ lineJoin: 'round',+ width: 4}),image: new CircleStyle({- radius: 5,+ radius: 7,stroke: new Stroke({color: 'rgba(0, 0, 0, 0.7)'}),diff --git a/web/js/map/ui.js b/web/js/map/ui.jsindex a60b0b520..f505f3f76 100644--- a/web/js/map/ui.js+++ b/web/js/map/ui.js@@ -158,7 +158,7 @@ export function mapui(models, config, store, ui) {// it is possible that config.projections somehow becomes array-like.lodashForOwn(config.projections, function(proj) {var map = createMap(proj);- map.measureTool = measure(map);+ map.measureTool = measure(map, proj.crs);self.proj[proj.id] = map;});models.map.events.on('update-layers', reloadLayers);diff --git a/web/js/util/util.js b/web/js/util/util.jsindex f7a2cd961..4d3a48587 100644--- a/web/js/util/util.js+++ b/web/js/util/util.js@@ -1060,6 +1060,13 @@ export default (function (self) {return formatted;};+ /**+ * Insert commas for numbers larger than 999+ */+ self.formatNumber = function (num) {++ };+self.toArray = function (value) {if (!value) {return [];