From cb6c6e0d9f5ccd43467c8da0b0dfcf7e51e1b9cf Mon Sep 17 00:00:00 2001 From: orangemug Date: Wed, 29 May 2019 18:54:32 +0100 Subject: [PATCH] Remove projection code for now. --- package.json | 1 - src/components/App.jsx | 6 ----- src/components/map/OpenLayersMap.jsx | 29 +++---------------------- src/components/modals/SettingsModal.jsx | 14 ------------ 4 files changed, 3 insertions(+), 47 deletions(-) diff --git a/package.json b/package.json index 7591efdd..6fe3fd18 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,6 @@ "maputnik-design": "github:maputnik/design", "ol": "^6.0.0-beta.8", "ol-mapbox-style": "^5.0.0-beta.2", - "proj4": "^2.5.0", "prop-types": "^15.6.2", "react": "^16.5.2", "react-aria-menubutton": "^6.0.1", diff --git a/src/components/App.jsx b/src/components/App.jsx index 2c088cdd..bd840268 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -483,11 +483,6 @@ export default class App extends React.Component { return metadata['maputnik:renderer'] || 'mbgljs'; } - getProjectionCode () { - const metadata = this.state.mapStyle.metadata || {}; - return this.state.openlayersDebugOptions.enableProjections ? metadata['maputnik:projection'] : "EPSG:3857"; - } - mapRenderer() { const metadata = this.state.mapStyle.metadata || {}; @@ -507,7 +502,6 @@ export default class App extends React.Component { if(renderer === 'ol') { mapElement = diff --git a/src/components/map/OpenLayersMap.jsx b/src/components/map/OpenLayersMap.jsx index f70bd2fa..cc87e1ec 100644 --- a/src/components/map/OpenLayersMap.jsx +++ b/src/components/map/OpenLayersMap.jsx @@ -9,15 +9,9 @@ import 'ol/ol.css' import {apply} from 'ol-mapbox-style'; import {Map, View, Proj, Overlay} from 'ol'; -import proj4 from 'proj4'; -import {register} from 'ol/proj/proj4'; -import {get as getProjection, toLonLat} from 'ol/proj'; +import {toLonLat} from 'ol/proj'; import {toStringHDMS} from 'ol/coordinate'; -// Register some projections... -proj4.defs('EPSG:3031', '+proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs '); -register(proj4); - function renderCoords (coords) { if (!coords || coords.length < 2) { @@ -64,21 +58,7 @@ export default class OpenLayersMap extends React.Component { apply(this.map, newMapStyle); } - updateProjection () { - this.projection = getProjection(this.props.projectionCode || "EPSG:3857"); - } - componentDidUpdate(prevProps) { - if (this.props.projectionCode !== prevProps.projectionCode) { - this.updateProjection(); - this.map.setView( - new View({ - projection: this.projection, - zoom: 1, - center: [180, -90] - }) - ); - } if (this.props.mapStyle !== prevProps.mapStyle) { this.updateStyle(this.props.mapStyle); } @@ -93,20 +73,17 @@ export default class OpenLayersMap extends React.Component { } }); - this.updateProjection(); - const map = new Map({ target: this.container, overlays: [this.overlay], view: new View({ - projection: this.projection, zoom: 1, center: [180, -90], }) }); map.on('pointermove', (evt) => { - var coords = toLonLat(evt.coordinate, this.projection); + var coords = toLonLat(evt.coordinate); this.setState({ cursor: [ coords[0].toFixed(2), @@ -116,7 +93,7 @@ export default class OpenLayersMap extends React.Component { }) map.on('postrender', (evt) => { - const center = toLonLat(map.getView().getCenter(), this.projection); + const center = toLonLat(map.getView().getCenter()); this.setState({ center: [ center[0].toFixed(2), diff --git a/src/components/modals/SettingsModal.jsx b/src/components/modals/SettingsModal.jsx index 80c93b4c..5e7e4ea9 100644 --- a/src/components/modals/SettingsModal.jsx +++ b/src/components/modals/SettingsModal.jsx @@ -110,20 +110,6 @@ class SettingsModal extends React.Component { /> - {this.props.openlayersDebugOptions.enableProjections && - - - - } - }