Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
b6fd4aaea8
|
|||
|
696d4b0ae3
|
@@ -57,9 +57,33 @@ export default class MapComponent extends Component {
|
|||||||
zIndex: 10, // Ensure it sits above the map tiles
|
zIndex: 10, // Ensure it sits above the map tiles
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Default view settings
|
||||||
|
let center = [99.05738, 7.55087];
|
||||||
|
let zoom = 13.0;
|
||||||
|
|
||||||
|
// Try to restore from localStorage
|
||||||
|
try {
|
||||||
|
const storedView = localStorage.getItem('marco:map-view');
|
||||||
|
if (storedView) {
|
||||||
|
const parsed = JSON.parse(storedView);
|
||||||
|
if (
|
||||||
|
parsed.center &&
|
||||||
|
Array.isArray(parsed.center) &&
|
||||||
|
parsed.center.length === 2 &&
|
||||||
|
typeof parsed.zoom === 'number'
|
||||||
|
) {
|
||||||
|
center = parsed.center;
|
||||||
|
zoom = parsed.zoom;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('Failed to restore map view:', e);
|
||||||
|
}
|
||||||
|
|
||||||
const view = new View({
|
const view = new View({
|
||||||
center: fromLonLat([99.05738, 7.55087]),
|
center: fromLonLat(center),
|
||||||
zoom: 13.0,
|
zoom: zoom,
|
||||||
projection: 'EPSG:3857',
|
projection: 'EPSG:3857',
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -341,6 +365,22 @@ export default class MapComponent extends Component {
|
|||||||
const bbox = { minLat, minLon, maxLat, maxLon };
|
const bbox = { minLat, minLon, maxLat, maxLon };
|
||||||
await this.storage.loadPlacesInBounds(bbox);
|
await this.storage.loadPlacesInBounds(bbox);
|
||||||
this.loadBookmarks(this.storage.savedPlaces);
|
this.loadBookmarks(this.storage.savedPlaces);
|
||||||
|
|
||||||
|
// Persist view to localStorage
|
||||||
|
try {
|
||||||
|
const view = this.mapInstance.getView();
|
||||||
|
const currentCenter = toLonLat(view.getCenter());
|
||||||
|
const currentZoom = view.getZoom();
|
||||||
|
|
||||||
|
const viewState = {
|
||||||
|
center: currentCenter,
|
||||||
|
zoom: currentZoom
|
||||||
|
};
|
||||||
|
|
||||||
|
localStorage.setItem('marco:map-view', JSON.stringify(viewState));
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('Failed to save map view:', e);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
handleMapClick = async (event) => {
|
handleMapClick = async (event) => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "marco",
|
"name": "marco",
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Small description for marco goes here",
|
"description": "Small description for marco goes here",
|
||||||
"repository": "",
|
"repository": "",
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -6,7 +6,7 @@
|
|||||||
<meta name="description" content="">
|
<meta name="description" content="">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
<script type="module" crossorigin src="/assets/main-PEcndiCZ.js"></script>
|
<script type="module" crossorigin src="/assets/main-BBfpqXeX.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/main-Dxork-AG.css">
|
<link rel="stylesheet" crossorigin href="/assets/main-Dxork-AG.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
Reference in New Issue
Block a user