Show the Markers layer whenever the district has locations
Switching the layer on only at the moment a location was saved was too narrow. loadLocations() runs at startup and after every change, and it left the layer hidden — so markers were visible right after saving and gone again on the next reload, which is what made it look as though closing Digitise had removed them. The call moves into loadLocations(), guarded on there being at least one location. That covers startup, saving, and any later refresh from one place, and the two calls in the add paths that duplicated it are gone. An empty district still opens with the layer off, which is what it was created hidden for. One trade-off, since it was asked about: an officer who deliberately unchecks Markers in the layer switcher will find it back on after the next reload or saved location. Respecting that choice would mean persisting it, which is worth doing only if anyone actually wants the layer off while holding locations. Verified both cases: with locations the layer goes visible on the startup load and stays visible through entering and leaving Digitise and through a reload; with none it stays hidden throughout. Service Worker v22 -> v23. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
5967b99a73
commit
56dd8cbda4
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
dist/assets/index-D2LXdMvQ.js.map
vendored
1
dist/assets/index-D2LXdMvQ.js.map
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
dist/assets/index-ErUYnuzo.js.map
vendored
Normal file
1
dist/assets/index-ErUYnuzo.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
2
dist/index.html
vendored
2
dist/index.html
vendored
@ -1917,7 +1917,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
<script type="module" crossorigin src="/assets/index-D2LXdMvQ.js"></script>
|
<script type="module" crossorigin src="/assets/index-ErUYnuzo.js"></script>
|
||||||
<link rel="modulepreload" crossorigin href="/assets/openlayers-J9qS6Th1.js">
|
<link rel="modulepreload" crossorigin href="/assets/openlayers-J9qS6Th1.js">
|
||||||
<link rel="modulepreload" crossorigin href="/assets/pako-Xa-UToif.js">
|
<link rel="modulepreload" crossorigin href="/assets/pako-Xa-UToif.js">
|
||||||
<link rel="modulepreload" crossorigin href="/assets/geotiff-BaoeLn6q.js">
|
<link rel="modulepreload" crossorigin href="/assets/geotiff-BaoeLn6q.js">
|
||||||
|
|||||||
7
dist/sw.js
vendored
7
dist/sw.js
vendored
@ -125,7 +125,12 @@
|
|||||||
// history: entering edit mode makes UndoRedo watch every source, so Undo
|
// history: entering edit mode makes UndoRedo watch every source, so Undo
|
||||||
// after saving a location used to strip the markers off the map while
|
// after saving a location used to strip the markers off the map while
|
||||||
// leaving the row in the database.
|
// leaving the row in the database.
|
||||||
const CACHE_VERSION = 'v22';
|
// v23: Showing the Markers layer moved into loadLocations(), so it holds
|
||||||
|
// whenever the district has locations — at startup and on every reload,
|
||||||
|
// not only in the moment a location is saved. Previously a reload put the
|
||||||
|
// layer back to hidden and every marker vanished. An empty district still
|
||||||
|
// opens with the layer off.
|
||||||
|
const CACHE_VERSION = 'v23';
|
||||||
const SHELL_CACHE = `shell-${CACHE_VERSION}`;
|
const SHELL_CACHE = `shell-${CACHE_VERSION}`;
|
||||||
const MODULES_CACHE = `modules-${CACHE_VERSION}`;
|
const MODULES_CACHE = `modules-${CACHE_VERSION}`;
|
||||||
const API_CACHE = `api-${CACHE_VERSION}`;
|
const API_CACHE = `api-${CACHE_VERSION}`;
|
||||||
|
|||||||
14
main.js
14
main.js
@ -397,10 +397,6 @@ async function initApp() {
|
|||||||
|
|
||||||
await loadLocations();
|
await loadLocations();
|
||||||
|
|
||||||
// The Markers layer starts hidden, so without this the point the officer
|
|
||||||
// just placed is written to the database and never drawn.
|
|
||||||
mapView?.showMarkers();
|
|
||||||
|
|
||||||
// Zoom to the new location on the map
|
// Zoom to the new location on the map
|
||||||
mapView?.zoomTo(data.lon, data.lat, 14);
|
mapView?.zoomTo(data.lon, data.lat, 14);
|
||||||
|
|
||||||
@ -853,9 +849,6 @@ async function handleAddLocation(event) {
|
|||||||
form.reset();
|
form.reset();
|
||||||
await loadLocations();
|
await loadLocations();
|
||||||
|
|
||||||
// As above: the Markers layer is hidden until something needs it shown.
|
|
||||||
mapView?.showMarkers();
|
|
||||||
|
|
||||||
// Zoom to the new location on the map
|
// Zoom to the new location on the map
|
||||||
mapView?.zoomTo(longitude, latitude, 14);
|
mapView?.zoomTo(longitude, latitude, 14);
|
||||||
|
|
||||||
@ -886,6 +879,13 @@ async function loadLocations() {
|
|||||||
mapView.clearMarkers();
|
mapView.clearMarkers();
|
||||||
if (locations.length > 0) {
|
if (locations.length > 0) {
|
||||||
mapView.addMarkers(locations);
|
mapView.addMarkers(locations);
|
||||||
|
// Show the layer whenever there is something in it. It is created
|
||||||
|
// hidden so an empty map opens clean, but a district that HAS locations
|
||||||
|
// should show them — otherwise every reload hides the markers again and
|
||||||
|
// the officer has to find the layer in the switcher to see work they
|
||||||
|
// already did. Doing it here covers startup and every reload, not just
|
||||||
|
// the moment a location is saved.
|
||||||
|
mapView.showMarkers();
|
||||||
console.log('[App] Added', locations.length, 'markers to map');
|
console.log('[App] Added', locations.length, 'markers to map');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -125,7 +125,12 @@
|
|||||||
// history: entering edit mode makes UndoRedo watch every source, so Undo
|
// history: entering edit mode makes UndoRedo watch every source, so Undo
|
||||||
// after saving a location used to strip the markers off the map while
|
// after saving a location used to strip the markers off the map while
|
||||||
// leaving the row in the database.
|
// leaving the row in the database.
|
||||||
const CACHE_VERSION = 'v22';
|
// v23: Showing the Markers layer moved into loadLocations(), so it holds
|
||||||
|
// whenever the district has locations — at startup and on every reload,
|
||||||
|
// not only in the moment a location is saved. Previously a reload put the
|
||||||
|
// layer back to hidden and every marker vanished. An empty district still
|
||||||
|
// opens with the layer off.
|
||||||
|
const CACHE_VERSION = 'v23';
|
||||||
const SHELL_CACHE = `shell-${CACHE_VERSION}`;
|
const SHELL_CACHE = `shell-${CACHE_VERSION}`;
|
||||||
const MODULES_CACHE = `modules-${CACHE_VERSION}`;
|
const MODULES_CACHE = `modules-${CACHE_VERSION}`;
|
||||||
const API_CACHE = `api-${CACHE_VERSION}`;
|
const API_CACHE = `api-${CACHE_VERSION}`;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user