diff --git a/src/components/map/MapboxGlMap.jsx b/src/components/map/MapboxGlMap.jsx index d677212b..3b04702c 100644 --- a/src/components/map/MapboxGlMap.jsx +++ b/src/components/map/MapboxGlMap.jsx @@ -134,14 +134,12 @@ export default class MapboxGlMap extends React.Component { const map = new MapboxGl.Map(mapOpts); - const center = map.getCenter(); - const zoom = map.getZoom(); - - this.setState({ - center, - zoom, - }); - this.props.onChange({center, zoom}); + const mapViewChange = () => { + const center = map.getCenter(); + const zoom = map.getZoom(); + this.props.onChange({center, zoom}); + } + mapViewChange(); map.showTileBoundaries = mapOpts.showTileBoundaries; map.showCollisionBoxes = mapOpts.showCollisionBoxes; @@ -206,19 +204,8 @@ export default class MapboxGlMap extends React.Component { }); }); - map.on("dragend", e => { - this.props.onChange({ - center: map.getCenter(), - zoom: this.state.zoom, - }) - }); - - map.on("zoomend", e => { - this.props.onChange({ - center: this.state.center, - zoom: map.getZoom(), - }) - }); + map.on("dragend", mapViewChange); + map.on("zoomend", mapViewChange); } render() { diff --git a/src/components/modals/DebugModal.js b/src/components/modals/DebugModal.js index eddeb0c8..181983f1 100644 --- a/src/components/modals/DebugModal.js +++ b/src/components/modals/DebugModal.js @@ -19,6 +19,10 @@ class DebugModal extends React.Component { render() { const {mapView} = this.props; + const osmZoom = Math.round(mapView.zoom)+1; + const osmLon = Number.parseFloat(mapView.center.lng).toFixed(5); + const osmLat = Number.parseFloat(mapView.center.lat).toFixed(5); + return Open in OSM — Opens the current view on openstreetmap.org