Skip to content

Commit

Permalink
Merge branch 'master' of github.com:heritagemap/frontend-pwa
Browse files Browse the repository at this point in the history
  • Loading branch information
Julia-Lavrova committed Jan 19, 2021
2 parents 2930f41 + 411a9ce commit 45203cd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/Map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class MyMap extends Component<MapPropsInterface, MyMapParams> {
longitude: this.props.match.params.lon,
});
}

const updatedViewport = JSON.stringify(this.state.viewport);
if (JSON.stringify(prevState.viewport) !== updatedViewport && window?.localStorage) {
window.localStorage.setItem('viewport', updatedViewport);
Expand All @@ -88,7 +89,7 @@ class MyMap extends Component<MapPropsInterface, MyMapParams> {
handleGeolocateViewportChange = (viewport: any) => {
const { longitude, latitude, zoom } = viewport;
const maxZoom = Math.max(MIN_ZOOM_LEVEL, Number(zoom));
const { lat, lon } = this.props.match.params;
const { lat, lon, id } = this.props.match.params;

this.setState((prevState) => (
{
Expand All @@ -103,16 +104,17 @@ class MyMap extends Component<MapPropsInterface, MyMapParams> {

this.loadPointsWithDebounce({ latitude, longitude, zoom: maxZoom });
if (lat !== latitude || lon !== longitude) {
this.props.history.push(getRoute({ lat: latitude, lon: longitude }));
this.props.history.push(getRoute({ lat: latitude, lon: longitude, id }));
}
};

handleGeolocate = ({ coords }: CoordsInterface) => {
const { longitude, latitude } = coords;
const { id } = this.props.match.params;
const { zoom } = this.state.viewport;

this.loadPointsWithDebounce({ latitude, longitude, zoom: zoom || MIN_ZOOM_LEVEL });
this.props.history.push(getRoute({ lat: latitude, lon: longitude }));
this.props.history.push(getRoute({ lat: latitude, lon: longitude, id }));
};

handleMapLoad = () => {
Expand Down

0 comments on commit 45203cd

Please sign in to comment.