Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the issue 1747: can't goto bounds in top page #1748

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 22 additions & 12 deletions src/pages/top.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,30 @@ import Portal from '@mui/material/Portal';
import Stack from '@mui/material/Stack';
import Typography from '@mui/material/Typography';
import log from 'loglevel';
import { useRouter } from 'next/router';
import React from 'react';
import FeaturedPlantersSlider from 'components/FeaturedPlantersSlider';
import FeaturedTreesSlider from 'components/FeaturedTreesSlider';
import HeadTag from 'components/HeadTag';
import LeaderBoard from 'components/LeaderBoard';
import SearchButton from 'components/SearchButton';
import TagChips from 'components/TagChips';
import Crumbs from 'components/common/Crumbs';
import Icon from 'components/common/CustomIcon';
import Filter from 'components/common/Filter';
import { useFullscreen } from 'hooks/globalHooks';
import Search from 'images/search.svg';
import { useMapContext } from 'mapContext';
import { getCountryLeaderboard, getFeaturedTrees } from 'models/api';
import FeaturedPlantersSlider from '../components/FeaturedPlantersSlider';
import FeaturedTreesSlider from '../components/FeaturedTreesSlider';
import LeaderBoard from '../components/LeaderBoard';
// import SearchFilter from '../components/SearchFilter';
import TagChips from '../components/TagChips';
import Crumbs from '../components/common/Crumbs';
import Icon from '../components/common/CustomIcon';
import Filter from '../components/common/Filter';
import { useFullscreen } from '../hooks/globalHooks';
import Search from '../images/search.svg';
import { useMapContext } from '../mapContext';
import * as utils from '../models/utils';
import * as pathResolver from 'models/pathResolver';
import * as utils from 'models/utils';

function Top(props) {
log.warn('props top:', props);
const { trees, planters, countries, organizations, wallets } = props;
// use map context to get the map
const { map } = useMapContext();
const router = useRouter();
const isFullscreen = useFullscreen();

const continentTags = [
Expand All @@ -47,6 +49,14 @@ function Top(props) {
async function reload() {
if (mapContext.map) {
await mapContext.map.setFilters({});
const bounds = pathResolver.getBounds(router);
if (bounds) {
log.warn('goto bounds found in url');
await mapContext.map.gotoBounds(bounds);
} else {
log.warn('goto global view');
await map.gotoView(0, 0, 2);
}
}
}
reload();
Expand Down
Loading