Karte: allow zooming past the deepest tile level
The map's zoom was capped at the deepest level that has tiles, which leaves almost no room on a shallow pyramid: a 1024px map only has levels 0 to 2, so fitBounds already landed at the maximum and the zoom-in button was disabled from the moment the page loaded. Reproduced against a copy of the live map (1024x1024, max_zoom 2): zoom-in disabled on load, clicking it did nothing. The tile layer now declares maxNativeZoom as the deepest level that really exists, and the map may zoom two levels beyond it - Leaflet scales those tiles up instead of requesting levels that would 404. Verified across the range: level 1 at zoom 1.25, native level 2 at zoom 2, and the same level 2 tiles upscaled to 362/512/724/1024px at zoom 2.5 through 4, with no request for the non-existent level 3. This also removes detectRetina, which made the problem worse rather than better: it costs a zoom level of magnification, not just resolution, so on a high-density display a three-level map lost a third of its already minimal range. tools/tile_viewer.html had the same constraint one level up and now allows two levels past native as well. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
52fea9f92d
commit
c1dacc6688
2 changed files with 15 additions and 13 deletions
|
|
@ -36,13 +36,12 @@
|
||||||
// die maximale Zoomstufe in Leaflet-Koordinaten uebersetzt - dadurch bleiben
|
// die maximale Zoomstufe in Leaflet-Koordinaten uebersetzt - dadurch bleiben
|
||||||
// sie auch dann richtig, wenn die Karte spaeter neu gekachelt wird.
|
// sie auch dann richtig, wenn die Karte spaeter neu gekachelt wird.
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
// Auf Bildschirmen mit hoher Pixeldichte (Retina, 4K-Laptops, Handys) entspricht ein
|
// Ueber die tiefste vorhandene Kachelebene hinaus darf weiter gezoomt werden; dort
|
||||||
// CSS-Pixel mehreren echten Pixeln - die oberste Zoomstufe wuerde dort hochskaliert und
|
// vergroessert Leaflet die tiefsten Kacheln (etwas weicher, aber man kommt naeher
|
||||||
// damit unscharf. Leaflet holt mit detectRetina stattdessen die naechsthoehere
|
// heran). Ohne das waere bei einer flachen Pyramide - eine 1024er-Karte hat nur die
|
||||||
// Kachelstufe und zeichnet sie halb so gross: gleiche Vergroesserung, aber pixelgenau.
|
// Stufen 0 bis 2 - schon die Startansicht am Anschlag und Hineinzoomen unmoeglich.
|
||||||
// Dafuer steht eine Zoomstufe weniger zur Verfuegung, deshalb hier abgezogen.
|
var EXTRA_ZOOM = 2;
|
||||||
var retina = L.Browser.retina && manifest.max_zoom > manifest.min_zoom;
|
var mapMaxZoom = manifest.max_zoom + EXTRA_ZOOM;
|
||||||
var mapMaxZoom = retina ? manifest.max_zoom - 1 : manifest.max_zoom;
|
|
||||||
|
|
||||||
var map = L.map('map-canvas', {
|
var map = L.map('map-canvas', {
|
||||||
crs: L.CRS.Simple,
|
crs: L.CRS.Simple,
|
||||||
|
|
@ -86,8 +85,10 @@
|
||||||
L.tileLayer(manifest.url_template, {
|
L.tileLayer(manifest.url_template, {
|
||||||
tileSize: manifest.tile_size,
|
tileSize: manifest.tile_size,
|
||||||
minZoom: manifest.min_zoom,
|
minZoom: manifest.min_zoom,
|
||||||
maxZoom: manifest.max_zoom,
|
maxZoom: mapMaxZoom,
|
||||||
detectRetina: true,
|
// Bis hierher gibt es wirklich Kacheln - alles darueber wird aus dieser Stufe
|
||||||
|
// hochskaliert, statt Kacheln anzufordern, die es nicht gibt.
|
||||||
|
maxNativeZoom: manifest.max_zoom,
|
||||||
bounds: bounds,
|
bounds: bounds,
|
||||||
noWrap: true,
|
noWrap: true,
|
||||||
// Randkacheln jenseits des Bildes gibt es nicht - statt eines kaputten
|
// Randkacheln jenseits des Bildes gibt es nicht - statt eines kaputten
|
||||||
|
|
|
||||||
|
|
@ -234,13 +234,14 @@ function screenToWorldY(sy) { return (sy - viewH / 2) / k + camY; }
|
||||||
* Auf Ebene z deckt ein Bildpixel 2^(ZMAX-z) Weltpixel ab, nativ gilt also
|
* Auf Ebene z deckt ein Bildpixel 2^(ZMAX-z) Weltpixel ab, nativ gilt also
|
||||||
* k * dpr * 2^(ZMAX-z) = 1. Fuer die hoechste Ebene (z = ZMAX) heisst das k = 1/dpr.
|
* k * dpr * 2^(ZMAX-z) = 1. Fuer die hoechste Ebene (z = ZMAX) heisst das k = 1/dpr.
|
||||||
*
|
*
|
||||||
* Laut Vorgabe darf der Nutzer die nutzbare Detailspanne um hoechstens eine Ebene
|
* Nach oben sind zwei Ebenen ueber nativ erlaubt (vierfache Vergroesserung), nach unten
|
||||||
* verlassen: nach oben also eine Verdopplung ueber nativ hinaus, nach unten eine
|
* eine Halbierung unter "ganze Welt passt ins Fenster". Zwei statt einer Ebene deshalb,
|
||||||
* Halbierung unter "ganze Welt passt ins Fenster".
|
* weil flache Pyramiden sonst kaum Spielraum lassen: eine 1024er-Karte hat nur die
|
||||||
|
* Stufen 0 bis 2, da waere die Startansicht schon fast am Anschlag.
|
||||||
*/
|
*/
|
||||||
function scaleBounds() {
|
function scaleBounds() {
|
||||||
const fit = Math.min(viewW, viewH) / WORLD;
|
const fit = Math.min(viewW, viewH) / WORLD;
|
||||||
return { min: fit / 2, max: 2 / dpr };
|
return { min: fit / 2, max: 4 / dpr };
|
||||||
}
|
}
|
||||||
|
|
||||||
function clampScale(value) {
|
function clampScale(value) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue