Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

revise container style and els, revise format setting

Ed Platoc975c283fa30
diff --git a/web/css/map.css b/web/css/map.css
index 490f10d31..44312f1b8 100644
--- a/web/css/map.css
+++ b/web/css/map.css
@@ -173,10 +173,11 @@
.wv-coords-container {
position: absolute;
height: 35px;
- width: 256px;
+ width: 260px;
top: auto;
right: 10px;
bottom: 103px;
+ overflow: hidden;
}
.wv-coords-map {
@@ -209,15 +210,17 @@
background-position: 0;
}
+.map-coord-format {
+ float: right;
+ pointer-events: none;
+}
+
.wv-coords-map span.map-coord {
line-height: 35px;
float: left;
height: 35px;
vertical-align: middle;
-}
-
-.wv-coords-map span.map-coord.latlon-selected {
- display: inline-block !important;
+ pointer-events: none;
}
.wv-coords-map div.coord-btn {
diff --git a/web/js/components/map/__snapshots__/coordinates.test.js.snap b/web/js/components/map/__snapshots__/coordinates.test.js.snap
index 8e7f928f8..484e00533 100644
--- a/web/js/components/map/__snapshots__/coordinates.test.js.snap
+++ b/web/js/components/map/__snapshots__/coordinates.test.js.snap
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`formats coordinate in latlon-dd format 1`] = `"<div id=\\"coords-panel\\" class=\\"wv-coords-map wv-coords-map-btn\\"><span class=\\"map-coord\\">0.0000°, 0.0000° EPSG:4326</span><div aria-label=\\"Change coordinates format\\" class=\\"coord-btn\\"><i class=\\"coord-switch\\"></i></div></div>"`;
+exports[`formats coordinate in latlon-dd format 1`] = `"<div id=\\"coords-panel\\" class=\\"wv-coords-map wv-coords-map-btn\\"><span class=\\"map-coord\\">0.0000°, 0.0000°</span><div class=\\"map-coord-format\\"><span class=\\"map-coord\\">EPSG:4326</span><div aria-label=\\"Change coordinates format\\" class=\\"coord-btn\\"><i class=\\"coord-switch\\"></i></div></div></div>"`;
-exports[`formats coordinate in latlon-dm format 1`] = `"<div id=\\"coords-panel\\" class=\\"wv-coords-map wv-coords-map-btn\\"><span class=\\"map-coord\\"> 0°00.000'N, 0°00.000'E EPSG:4326</span><div aria-label=\\"Change coordinates format\\" class=\\"coord-btn\\"><i class=\\"coord-switch\\"></i></div></div>"`;
+exports[`formats coordinate in latlon-dm format 1`] = `"<div id=\\"coords-panel\\" class=\\"wv-coords-map wv-coords-map-btn\\"><span class=\\"map-coord\\"> 0°00.000'N, 0°00.000'E</span><div class=\\"map-coord-format\\"><span class=\\"map-coord\\">EPSG:4326</span><div aria-label=\\"Change coordinates format\\" class=\\"coord-btn\\"><i class=\\"coord-switch\\"></i></div></div></div>"`;
-exports[`formats coordinate in latlon-dms format 1`] = `"<div id=\\"coords-panel\\" class=\\"wv-coords-map wv-coords-map-btn\\"><span class=\\"map-coord\\"> 0°00'00\\"N, 0°00'00\\"E EPSG:4326</span><div aria-label=\\"Change coordinates format\\" class=\\"coord-btn\\"><i class=\\"coord-switch\\"></i></div></div>"`;
+exports[`formats coordinate in latlon-dms format 1`] = `"<div id=\\"coords-panel\\" class=\\"wv-coords-map wv-coords-map-btn\\"><span class=\\"map-coord\\"> 0°00'00\\"N, 0°00'00\\"E</span><div class=\\"map-coord-format\\"><span class=\\"map-coord\\">EPSG:4326</span><div aria-label=\\"Change coordinates format\\" class=\\"coord-btn\\"><i class=\\"coord-switch\\"></i></div></div></div>"`;
diff --git a/web/js/components/map/__snapshots__/ol-coordinates.test.js.snap b/web/js/components/map/__snapshots__/ol-coordinates.test.js.snap
index 42003eefb..8be4aa93c 100644
--- a/web/js/components/map/__snapshots__/ol-coordinates.test.js.snap
+++ b/web/js/components/map/__snapshots__/ol-coordinates.test.js.snap
@@ -1,11 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`clears coordinates when mouse moves off the map 1`] = `"<div id=\\"ol-coords-case\\" class=\\"wv-coords-container\\"></div>"`;
+exports[`clears coordinates when mouse moves off the map 1`] = `"<div id=\\"ol-coords-case\\" class=\\"wv-coords-container\\" style=\\"width: 230px;\\"></div>"`;
-exports[`reprojects (0,0) to (-45, 90) for EPSG:3413 1`] = `"<div id=\\"ol-coords-case\\" class=\\"wv-coords-container\\"><div id=\\"coords-panel\\" class=\\"wv-coords-map wv-coords-map-btn\\"><span class=\\"map-coord\\">90.0000°, -45.0000° EPSG:3413</span><div aria-label=\\"Change coordinates format\\" class=\\"coord-btn\\"><i class=\\"coord-switch\\"></i></div></div></div>"`;
+exports[`reprojects (0,0) to (-45, 90) for EPSG:3413 1`] = `"<div id=\\"ol-coords-case\\" class=\\"wv-coords-container\\" style=\\"width: 230px;\\"><div id=\\"coords-panel\\" class=\\"wv-coords-map wv-coords-map-btn\\"><span class=\\"map-coord\\">90.0000°, -45.0000°</span><div class=\\"map-coord-format\\"><span class=\\"map-coord\\">EPSG:3413</span><div aria-label=\\"Change coordinates format\\" class=\\"coord-btn\\"><i class=\\"coord-switch\\"></i></div></div></div></div>"`;
-exports[`shows 20°00.000'N, 10°00.000'E when set to degrees and minutes format 1`] = `"<div id=\\"ol-coords-case\\" class=\\"wv-coords-container\\"><div id=\\"coords-panel\\" class=\\"wv-coords-map wv-coords-map-btn\\"><span class=\\"map-coord\\">20°00.000'N, 10°00.000'E EPSG:4326</span><div aria-label=\\"Change coordinates format\\" class=\\"coord-btn\\"><i class=\\"coord-switch\\"></i></div></div></div>"`;
+exports[`shows 20°00.000'N, 10°00.000'E when set to degrees and minutes format 1`] = `"<div id=\\"ol-coords-case\\" class=\\"wv-coords-container\\" style=\\"width: 230px;\\"><div id=\\"coords-panel\\" class=\\"wv-coords-map wv-coords-map-btn\\"><span class=\\"map-coord\\">20.0000°, 10.0000°</span><div class=\\"map-coord-format\\"><span class=\\"map-coord\\">EPSG:4326</span><div aria-label=\\"Change coordinates format\\" class=\\"coord-btn\\"><i class=\\"coord-switch\\"></i></div></div></div></div>"`;
-exports[`shows coordinates of (-160, 20) when moving the mouse over wrapped 1`] = `"<div id=\\"ol-coords-case\\" class=\\"wv-coords-container\\"><div id=\\"coords-panel\\" class=\\"wv-coords-map wv-coords-map-btn\\"><span class=\\"map-coord\\">20.0000°, -160.0000° EPSG:4326</span><div aria-label=\\"Change coordinates format\\" class=\\"coord-btn\\"><i class=\\"coord-switch\\"></i></div></div></div>"`;
+exports[`shows coordinates of (-160, 20) when moving the mouse over wrapped 1`] = `"<div id=\\"ol-coords-case\\" class=\\"wv-coords-container\\" style=\\"width: 230px;\\"><div id=\\"coords-panel\\" class=\\"wv-coords-map wv-coords-map-btn\\"><span class=\\"map-coord\\">20.0000°, -160.0000°</span><div class=\\"map-coord-format\\"><span class=\\"map-coord\\">EPSG:4326</span><div aria-label=\\"Change coordinates format\\" class=\\"coord-btn\\"><i class=\\"coord-switch\\"></i></div></div></div></div>"`;
-exports[`shows coordinates of (10, 20) when moving the mouse 1`] = `"<div id=\\"ol-coords-case\\" class=\\"wv-coords-container\\"><div id=\\"coords-panel\\" class=\\"wv-coords-map wv-coords-map-btn\\"><span class=\\"map-coord\\">20.0000°, 10.0000° EPSG:4326</span><div aria-label=\\"Change coordinates format\\" class=\\"coord-btn\\"><i class=\\"coord-switch\\"></i></div></div></div>"`;
+exports[`shows coordinates of (10, 20) when moving the mouse 1`] = `"<div id=\\"ol-coords-case\\" class=\\"wv-coords-container\\" style=\\"width: 230px;\\"><div id=\\"coords-panel\\" class=\\"wv-coords-map wv-coords-map-btn\\"><span class=\\"map-coord\\">20.0000°, 10.0000°</span><div class=\\"map-coord-format\\"><span class=\\"map-coord\\">EPSG:4326</span><div aria-label=\\"Change coordinates format\\" class=\\"coord-btn\\"><i class=\\"coord-switch\\"></i></div></div></div></div>"`;
diff --git a/web/js/components/map/coordinates.js b/web/js/components/map/coordinates.js
index 87d2eaae0..e7cdad374 100644
--- a/web/js/components/map/coordinates.js
+++ b/web/js/components/map/coordinates.js
@@ -48,10 +48,15 @@ export default class Coordinates extends React.Component {
Change coordinates format
</UncontrolledTooltip>
<span className="map-coord">
- {`${coords} ${crs}`}
+ {`${coords}`}
</span>
- <div aria-label="Change coordinates format" className="coord-btn">
- <i className="coord-switch" />
+ <div className="map-coord-format">
+ <span className="map-coord">
+ {`${crs}`}
+ </span>
+ <div aria-label="Change coordinates format" className="coord-btn">
+ <i className="coord-switch" />
+ </div>
</div>
</div>
);
diff --git a/web/js/components/map/ol-coordinates.js b/web/js/components/map/ol-coordinates.js
index ca7e1ccc6..1b42561b7 100644
--- a/web/js/components/map/ol-coordinates.js
+++ b/web/js/components/map/ol-coordinates.js
@@ -4,6 +4,14 @@ import Coordinates from './coordinates';
import util from '../../util/util';
const { events } = util;
+const getContainerWidth = (format) => {
+ const formatWidth = {
+ 'latlon-dd': 230,
+ 'latlon-dm': 265,
+ 'latlon-dms': 255,
+ };
+ return formatWidth[format];
+};
export default class OlCoordinates extends React.Component {
constructor(props) {
@@ -14,15 +22,18 @@ export default class OlCoordinates extends React.Component {
longitude: null,
crs: null,
format: null,
+ width: null,
};
this.mouseMove = this.mouseMove.bind(this);
this.mouseOut = this.mouseOut.bind(this);
this.changeFormat = this.changeFormat.bind(this);
+ this.setInitFormat = this.setInitFormat.bind(this);
}
componentDidMount() {
events.on('map:mousemove', this.mouseMove);
events.on('map:mouseout', this.mouseOut);
+ this.setInitFormat();
}
componentWillUnmount() {
@@ -55,7 +66,6 @@ export default class OlCoordinates extends React.Component {
}
this.setState({
hasMouse: true,
- format: util.getCoordinateFormat(),
latitude: pcoord[1],
longitude: pcoord[0],
crs,
@@ -67,7 +77,7 @@ export default class OlCoordinates extends React.Component {
const cl = event.relatedTarget.classList;
// Ignore when the mouse goes over the coordinate display. Clearing
// the coordinates in this situation causes a flicker.
- if (cl.contains('map-coord')) {
+ if (cl.contains('wv-coords-map')) {
return;
}
}
@@ -78,14 +88,27 @@ export default class OlCoordinates extends React.Component {
this.setState({ latitude: null, longitude: null });
}
+ setInitFormat() {
+ const format = util.getCoordinateFormat();
+ const width = getContainerWidth(format);
+ this.setState({
+ format,
+ width,
+ });
+ }
+
changeFormat(format) {
util.setCoordinateFormat(format);
- this.setState({ format });
+ const width = getContainerWidth(format);
+ this.setState({
+ format,
+ width,
+ });
}
render() {
const {
- hasMouse, format, latitude, longitude, crs,
+ hasMouse, format, latitude, longitude, crs, width,
} = this.state;
// Don't render until a mouse is being used
if (!hasMouse) {
@@ -93,7 +116,7 @@ export default class OlCoordinates extends React.Component {
}
return (
- <div id="ol-coords-case" className="wv-coords-container">
+ <div id="ol-coords-case" className="wv-coords-container" style={{ width }}>
<Coordinates
format={format}
latitude={latitude}