Skip to content

Commit 98e7dd6

Browse files
committed
Improve marker performance/visuals
1 parent 0163a6e commit 98e7dd6

3 files changed

Lines changed: 41 additions & 4 deletions

File tree

app.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ function initMap() {
100100
minZoom: 5, // Prevent zooming out too far
101101
maxZoom: 19, // Allow detailed street-level zoom
102102
maxBounds: australiaBounds, // Restrict panning to Australia
103-
maxBoundsViscosity: 0.8 // Make bounds "sticky" (0.0 = soft, 1.0 = hard boundaries)
103+
maxBoundsViscosity: 0.8, // Make bounds "sticky" (0.0 = soft, 1.0 = hard boundaries)
104+
zoomAnimation: false, // Disable zoom animation so markers update instantly
105+
fadeAnimation: true // Smooth tile fade prevents flicker
104106
});
105107

106108
// Define multiple base map layers
@@ -147,7 +149,8 @@ function initMap() {
147149
// Initialize layers
148150
markersLayer = L.markerClusterGroup({
149151
chunkedLoading: true,
150-
chunkDelay: 50, // Reduced from default 200ms for faster loading
152+
chunkDelay: 1, // Near-instant chunk processing (1ms)
153+
chunkInterval: 200, // Process 200 markers per chunk for faster completion
151154
chunkProgress: null, // Disable progress updates for better performance
152155
spiderfyOnMaxZoom: true,
153156
showCoverageOnHover: false,
@@ -157,7 +160,8 @@ function initMap() {
157160
return zoom < 10 ? 80 : (zoom < 13 ? 60 : 50);
158161
},
159162
disableClusteringAtZoom: 19, // Disable clustering when fully zoomed in
160-
animate: false, // Disable animations for faster rendering
163+
animate: true, // Enable smooth animations during zoom
164+
animateAddingMarkers: true, // Enable fade-in animations for markers
161165
removeOutsideVisibleBounds: true, // Remove markers outside viewport
162166
iconCreateFunction: function(cluster) {
163167
const childCount = cluster.getChildCount();

service-worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Service Worker for SA Crash Data Map
22
// Implements caching strategies for offline support and performance
33

4-
const VERSION = '1.0.46';
4+
const VERSION = '1.0.48';
55
const CACHE_NAME = `crash-map-static-v${VERSION}`;
66
const DATA_CACHE_NAME = `crash-map-data-v${VERSION}`;
77
const RUNTIME_CACHE_NAME = `crash-map-runtime-v${VERSION}`;

styles.css

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,39 @@
7878
height: 100vh;
7979
width: 100%;
8080
z-index: 1;
81+
background-color: #1a1a1a; /* Dark background prevents white flash during tile loading */
82+
}
83+
84+
/* Hardware acceleration for smoother zoom/pan */
85+
.leaflet-map-pane,
86+
.leaflet-tile-pane,
87+
.leaflet-overlay-pane,
88+
.leaflet-marker-pane {
89+
transform: translate3d(0, 0, 0);
90+
will-change: transform;
91+
}
92+
93+
/* Quick fade-in animation for markers and clusters */
94+
.leaflet-marker-icon,
95+
.marker-cluster {
96+
animation: markerFadeIn 0.15s cubic-bezier(0.4, 0, 0.2, 1);
97+
}
98+
99+
@keyframes markerFadeIn {
100+
from {
101+
opacity: 0;
102+
transform: scale(0.95);
103+
}
104+
to {
105+
opacity: 1;
106+
transform: scale(1);
107+
}
108+
}
109+
110+
/* Quick cluster split/merge during zoom */
111+
.leaflet-cluster-anim .leaflet-marker-icon,
112+
.leaflet-cluster-anim .leaflet-marker-shadow {
113+
transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.15s ease-out;
81114
}
82115

83116
.controls-panel {

0 commit comments

Comments
 (0)