mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2025-01-14 17:23:26 +01:00
Fixes lat/lon precision and center change via zoom without pan.
This commit is contained in:
parent
27e6675d26
commit
0009c74948
2 changed files with 13 additions and 22 deletions
|
@ -134,14 +134,12 @@ export default class MapboxGlMap extends React.Component {
|
||||||
|
|
||||||
const map = new MapboxGl.Map(mapOpts);
|
const map = new MapboxGl.Map(mapOpts);
|
||||||
|
|
||||||
const center = map.getCenter();
|
const mapViewChange = () => {
|
||||||
const zoom = map.getZoom();
|
const center = map.getCenter();
|
||||||
|
const zoom = map.getZoom();
|
||||||
this.setState({
|
this.props.onChange({center, zoom});
|
||||||
center,
|
}
|
||||||
zoom,
|
mapViewChange();
|
||||||
});
|
|
||||||
this.props.onChange({center, zoom});
|
|
||||||
|
|
||||||
map.showTileBoundaries = mapOpts.showTileBoundaries;
|
map.showTileBoundaries = mapOpts.showTileBoundaries;
|
||||||
map.showCollisionBoxes = mapOpts.showCollisionBoxes;
|
map.showCollisionBoxes = mapOpts.showCollisionBoxes;
|
||||||
|
@ -206,19 +204,8 @@ export default class MapboxGlMap extends React.Component {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
map.on("dragend", e => {
|
map.on("dragend", mapViewChange);
|
||||||
this.props.onChange({
|
map.on("zoomend", mapViewChange);
|
||||||
center: map.getCenter(),
|
|
||||||
zoom: this.state.zoom,
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
map.on("zoomend", e => {
|
|
||||||
this.props.onChange({
|
|
||||||
center: this.state.center,
|
|
||||||
zoom: map.getZoom(),
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -19,6 +19,10 @@ class DebugModal extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
const {mapView} = this.props;
|
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 <Modal
|
return <Modal
|
||||||
data-wd-key="debug-modal"
|
data-wd-key="debug-modal"
|
||||||
isOpen={this.props.isOpen}
|
isOpen={this.props.isOpen}
|
||||||
|
@ -56,7 +60,7 @@ class DebugModal extends React.Component {
|
||||||
<a
|
<a
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
href={`https://www.openstreetmap.org/#map=${Math.round(mapView.zoom)+1}/${mapView.center.lat}/${mapView.center.lng}`}
|
href={`https://www.openstreetmap.org/#map=${osmZoom}/${osmLat}/${osmLon}`}
|
||||||
>
|
>
|
||||||
Open in OSM
|
Open in OSM
|
||||||
</a> — Opens the current view on openstreetmap.org
|
</a> — Opens the current view on openstreetmap.org
|
||||||
|
|
Loading…
Reference in a new issue