Spaces:
Runtime error
Runtime error
Fix map zoom levels for optimal clustering view
Browse files- Set maxZoom to 16 to maintain clustering at all levels
- Changed initial zoom from 15 to 14 for better overview
- Set minZoom to 10 for consistent experience
- Updated cluster settings: larger radius (80px) for better grouping
- Disabled clustering only at max zoom (16) instead of 17
- Auto-center uses maxZoom 15 to preserve clustering
- Removed auto-zoom to level 18 that broke clustering
- Map now opens with same view as 'Center View' button provides
- static/index.html +2 -2
- static/map.html +2 -2
- static/map.js +19 -21
- static/sw.js +1 -1
- version.json +1 -1
static/index.html
CHANGED
|
@@ -947,7 +947,7 @@
|
|
| 947 |
// Force refresh if we detect cached version
|
| 948 |
(function() {
|
| 949 |
const currentVersion = '5.1.1';
|
| 950 |
-
const timestamp = '
|
| 951 |
const lastVersion = sessionStorage.getItem('treetrack_version');
|
| 952 |
const lastTimestamp = sessionStorage.getItem('treetrack_timestamp');
|
| 953 |
|
|
@@ -1193,7 +1193,7 @@
|
|
| 1193 |
</div>
|
| 1194 |
</div>
|
| 1195 |
|
| 1196 |
-
<script type="module" src="/static/js/tree-track-app.js?v=5.1.1&t=
|
| 1197 |
|
| 1198 |
<script>
|
| 1199 |
// Idle-time prefetch of map assets to speed up first navigation
|
|
|
|
| 947 |
// Force refresh if we detect cached version
|
| 948 |
(function() {
|
| 949 |
const currentVersion = '5.1.1';
|
| 950 |
+
const timestamp = '1761507045'; // Cache-busting bump
|
| 951 |
const lastVersion = sessionStorage.getItem('treetrack_version');
|
| 952 |
const lastTimestamp = sessionStorage.getItem('treetrack_timestamp');
|
| 953 |
|
|
|
|
| 1193 |
</div>
|
| 1194 |
</div>
|
| 1195 |
|
| 1196 |
+
<script type="module" src="/static/js/tree-track-app.js?v=5.1.1&t=1761507045"></script>
|
| 1197 |
|
| 1198 |
<script>
|
| 1199 |
// Idle-time prefetch of map assets to speed up first navigation
|
static/map.html
CHANGED
|
@@ -928,7 +928,7 @@
|
|
| 928 |
// Force refresh if we detect cached version
|
| 929 |
(function() {
|
| 930 |
const currentVersion = '5.1.1';
|
| 931 |
-
const timestamp = '
|
| 932 |
const lastVersion = sessionStorage.getItem('treetrack_version');
|
| 933 |
const lastTimestamp = sessionStorage.getItem('treetrack_timestamp');
|
| 934 |
|
|
@@ -1081,7 +1081,7 @@ const timestamp = '1761506574'; // Current timestamp for cache busting
|
|
| 1081 |
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
|
| 1082 |
<!-- Leaflet MarkerCluster JS for performance and grouping -->
|
| 1083 |
<script src="https://unpkg.com/leaflet.markercluster@1.4.1/dist/leaflet.markercluster.js"></script>
|
| 1084 |
-
<script src="/static/map.js?v=5.1.1&t=
|
| 1085 |
|
| 1086 |
"default-state": {
|
| 1087 |
gradients: [
|
|
|
|
| 928 |
// Force refresh if we detect cached version
|
| 929 |
(function() {
|
| 930 |
const currentVersion = '5.1.1';
|
| 931 |
+
const timestamp = '1761507045'; // Current timestamp for cache busting
|
| 932 |
const lastVersion = sessionStorage.getItem('treetrack_version');
|
| 933 |
const lastTimestamp = sessionStorage.getItem('treetrack_timestamp');
|
| 934 |
|
|
|
|
| 1081 |
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
|
| 1082 |
<!-- Leaflet MarkerCluster JS for performance and grouping -->
|
| 1083 |
<script src="https://unpkg.com/leaflet.markercluster@1.4.1/dist/leaflet.markercluster.js"></script>
|
| 1084 |
+
<script src="/static/map.js?v=5.1.1&t=1761507045">
|
| 1085 |
|
| 1086 |
"default-state": {
|
| 1087 |
gradients: [
|
static/map.js
CHANGED
|
@@ -255,31 +255,34 @@ class TreeTrackMap {
|
|
| 255 |
// Center on Tezpur, Assam - the actual research area
|
| 256 |
const tezpurLocation = [26.6340, 92.7840]; // Tezpur coordinates
|
| 257 |
|
| 258 |
-
// Initialize map with
|
| 259 |
this.map = L.map('map', {
|
| 260 |
center: tezpurLocation,
|
| 261 |
-
zoom:
|
|
|
|
|
|
|
| 262 |
zoomControl: true,
|
| 263 |
attributionControl: true,
|
| 264 |
preferCanvas: true // Better performance for many markers
|
| 265 |
});
|
| 266 |
|
| 267 |
-
// Add multiple beautiful tile layers
|
| 268 |
const satelliteLayer = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
|
| 269 |
attribution: 'Tiles © Esri — Source: Esri, Maxar, GeoEye, Earthstar Geographics, CNES/Airbus DS, USDA, AeroGRID, IGN, and the GIS User Community',
|
| 270 |
-
maxZoom:
|
| 271 |
-
minZoom:
|
| 272 |
});
|
| 273 |
|
| 274 |
const terrainLayer = L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}{r}.png', {
|
| 275 |
attribution: 'Map tiles by Stamen Design, CC BY 3.0 — Map data © OpenStreetMap contributors',
|
| 276 |
maxZoom: 16,
|
| 277 |
-
minZoom:
|
| 278 |
});
|
| 279 |
|
| 280 |
const streetLayer = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
| 281 |
attribution: '© OpenStreetMap contributors',
|
| 282 |
-
maxZoom:
|
|
|
|
| 283 |
});
|
| 284 |
|
| 285 |
// Use satellite as primary layer for Tezpur's natural beauty
|
|
@@ -294,18 +297,18 @@ class TreeTrackMap {
|
|
| 294 |
|
| 295 |
L.control.layers(baseMaps).addTo(this.map);
|
| 296 |
|
| 297 |
-
// Initialize marker clustering optimized for
|
| 298 |
this.markerClusterGroup = L.markerClusterGroup({
|
| 299 |
chunkedLoading: true,
|
| 300 |
chunkInterval: 100, // Faster processing for single query
|
| 301 |
chunkDelay: 25, // Reduced delay
|
| 302 |
-
maxClusterRadius:
|
| 303 |
spiderfyOnMaxZoom: true,
|
| 304 |
showCoverageOnHover: false,
|
| 305 |
zoomToBoundsOnClick: true,
|
| 306 |
removeOutsideVisibleBounds: true, // Performance optimization
|
| 307 |
animate: true,
|
| 308 |
-
disableClusteringAtZoom:
|
| 309 |
});
|
| 310 |
|
| 311 |
this.map.addLayer(this.markerClusterGroup);
|
|
@@ -493,9 +496,9 @@ class TreeTrackMap {
|
|
| 493 |
return;
|
| 494 |
}
|
| 495 |
|
| 496 |
-
// Fit map to show all trees
|
| 497 |
const group = new L.featureGroup(this.treeMarkers);
|
| 498 |
-
this.map.fitBounds(group.getBounds().pad(0.1));
|
| 499 |
this.showMessage('Map centered on all trees', 'success');
|
| 500 |
}
|
| 501 |
|
|
@@ -673,21 +676,16 @@ class TreeTrackMap {
|
|
| 673 |
}, (i / uiBatchSize) * 50); // Stagger UI batches by 50ms
|
| 674 |
}
|
| 675 |
|
| 676 |
-
// Auto-
|
| 677 |
setTimeout(() => {
|
| 678 |
if (loadedCount > 0) {
|
| 679 |
// Get bounds of all tree markers
|
| 680 |
const group = new L.featureGroup(this.treeMarkers);
|
| 681 |
const bounds = group.getBounds();
|
| 682 |
|
| 683 |
-
// Center on trees
|
| 684 |
-
this.map.fitBounds(bounds, { padding: [20, 20] });
|
| 685 |
-
|
| 686 |
-
// After fitting bounds, zoom to maximum detailed level
|
| 687 |
-
setTimeout(() => {
|
| 688 |
-
this.map.setZoom(18); // Maximum detailed zoom
|
| 689 |
-
console.log('Map auto-zoomed to maximum detail level');
|
| 690 |
-
}, 500);
|
| 691 |
}
|
| 692 |
}, 2000); // Wait for most UI batches to complete
|
| 693 |
|
|
|
|
| 255 |
// Center on Tezpur, Assam - the actual research area
|
| 256 |
const tezpurLocation = [26.6340, 92.7840]; // Tezpur coordinates
|
| 257 |
|
| 258 |
+
// Initialize map with optimal clustering zoom level
|
| 259 |
this.map = L.map('map', {
|
| 260 |
center: tezpurLocation,
|
| 261 |
+
zoom: 14, // Start with clustering view
|
| 262 |
+
maxZoom: 16, // Limit maximum zoom to maintain clustering
|
| 263 |
+
minZoom: 10, // Set reasonable minimum zoom
|
| 264 |
zoomControl: true,
|
| 265 |
attributionControl: true,
|
| 266 |
preferCanvas: true // Better performance for many markers
|
| 267 |
});
|
| 268 |
|
| 269 |
+
// Add multiple beautiful tile layers with clustering-optimized zoom limits
|
| 270 |
const satelliteLayer = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
|
| 271 |
attribution: 'Tiles © Esri — Source: Esri, Maxar, GeoEye, Earthstar Geographics, CNES/Airbus DS, USDA, AeroGRID, IGN, and the GIS User Community',
|
| 272 |
+
maxZoom: 16, // Match map maxZoom for consistency
|
| 273 |
+
minZoom: 10
|
| 274 |
});
|
| 275 |
|
| 276 |
const terrainLayer = L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}{r}.png', {
|
| 277 |
attribution: 'Map tiles by Stamen Design, CC BY 3.0 — Map data © OpenStreetMap contributors',
|
| 278 |
maxZoom: 16,
|
| 279 |
+
minZoom: 10
|
| 280 |
});
|
| 281 |
|
| 282 |
const streetLayer = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
| 283 |
attribution: '© OpenStreetMap contributors',
|
| 284 |
+
maxZoom: 16,
|
| 285 |
+
minZoom: 10
|
| 286 |
});
|
| 287 |
|
| 288 |
// Use satellite as primary layer for Tezpur's natural beauty
|
|
|
|
| 297 |
|
| 298 |
L.control.layers(baseMaps).addTo(this.map);
|
| 299 |
|
| 300 |
+
// Initialize marker clustering optimized for overview clustering
|
| 301 |
this.markerClusterGroup = L.markerClusterGroup({
|
| 302 |
chunkedLoading: true,
|
| 303 |
chunkInterval: 100, // Faster processing for single query
|
| 304 |
chunkDelay: 25, // Reduced delay
|
| 305 |
+
maxClusterRadius: 80, // Larger radius for better clustering
|
| 306 |
spiderfyOnMaxZoom: true,
|
| 307 |
showCoverageOnHover: false,
|
| 308 |
zoomToBoundsOnClick: true,
|
| 309 |
removeOutsideVisibleBounds: true, // Performance optimization
|
| 310 |
animate: true,
|
| 311 |
+
disableClusteringAtZoom: 16 // Keep clustering active until max zoom
|
| 312 |
});
|
| 313 |
|
| 314 |
this.map.addLayer(this.markerClusterGroup);
|
|
|
|
| 496 |
return;
|
| 497 |
}
|
| 498 |
|
| 499 |
+
// Fit map to show all trees with clustering-friendly zoom
|
| 500 |
const group = new L.featureGroup(this.treeMarkers);
|
| 501 |
+
this.map.fitBounds(group.getBounds().pad(0.1), { maxZoom: 15 });
|
| 502 |
this.showMessage('Map centered on all trees', 'success');
|
| 503 |
}
|
| 504 |
|
|
|
|
| 676 |
}, (i / uiBatchSize) * 50); // Stagger UI batches by 50ms
|
| 677 |
}
|
| 678 |
|
| 679 |
+
// Auto-center on trees with clustering-friendly zoom after loading completes
|
| 680 |
setTimeout(() => {
|
| 681 |
if (loadedCount > 0) {
|
| 682 |
// Get bounds of all tree markers
|
| 683 |
const group = new L.featureGroup(this.treeMarkers);
|
| 684 |
const bounds = group.getBounds();
|
| 685 |
|
| 686 |
+
// Center on trees with clustering-optimized zoom level
|
| 687 |
+
this.map.fitBounds(bounds, { padding: [20, 20], maxZoom: 15 });
|
| 688 |
+
console.log('Map auto-centered on trees with clustering view');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 689 |
}
|
| 690 |
}, 2000); // Wait for most UI batches to complete
|
| 691 |
|
static/sw.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
// TreeTrack Service Worker - PWA and Offline Support
|
| 2 |
-
const VERSION =
|
| 3 |
const CACHE_NAME = `treetrack-v${VERSION}`;
|
| 4 |
const STATIC_CACHE = `static-v${VERSION}`;
|
| 5 |
const API_CACHE = `api-v${VERSION}`;
|
|
|
|
| 1 |
// TreeTrack Service Worker - PWA and Offline Support
|
| 2 |
+
const VERSION = 1761507045; // Cache busting bump - force clients to fetch new static assets and header image change
|
| 3 |
const CACHE_NAME = `treetrack-v${VERSION}`;
|
| 4 |
const STATIC_CACHE = `static-v${VERSION}`;
|
| 5 |
const API_CACHE = `api-v${VERSION}`;
|
version.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
{
|
| 2 |
"version": "5.1.1",
|
| 3 |
-
"timestamp":
|
| 4 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"version": "5.1.1",
|
| 3 |
+
"timestamp": 1761507045
|
| 4 |
}
|