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

fixed map location error #899

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
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
14 changes: 7 additions & 7 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions frontend/src/components/MapboxMap/MapboxMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@ const MapboxMap: React.FC<MapboxMapProps> = ({ centerLng = 28.23142, centerLat =
];

if (centerOnMuni) {
// center map on municipality only if specified
[centerLng, centerLat] = getMuniLngLat() || [centerLng, centerLat];
}
else {
// center map on user's location if available
const userLocation = await getUserLocation();
[centerLng, centerLat] = userLocation || [centerLng, centerLat];
// center map on municipality if specified and available, but fallback to user's location or default on failure
const municipalityLocation = getMuniLngLat();

if (municipalityLocation) {
[centerLng, centerLat] = municipalityLocation;
}
else {
const userLocation = await getUserLocation();
[centerLng, centerLat] = userLocation || [centerLng, centerLat];
}
}

const initializedMap = new mapboxgl.Map({
Expand Down