From 6055998795949bb3d03c73d4fb368cbefd1b54c3 Mon Sep 17 00:00:00 2001 From: Ives De Bruycker Date: Mon, 23 Jun 2025 11:48:20 +0200 Subject: [PATCH 1/2] Fix center off when using geojson --- src/template.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/template.html b/src/template.html index 39d659c..0b1567f 100644 --- a/src/template.html +++ b/src/template.html @@ -123,21 +123,21 @@ map.fitBounds(geojsonlayer.getBounds(), {maxZoom: maxZoom}); {{/if}} - {{#if center}} - map.panTo(L.latLng('{{ center }}'.split(',')[1], '{{ center }}'.split(',')[0]), {animate: false}); + {{#if zoom}} + map.setZoom({{ zoom }}, {animate: false}); {{else}} - {{#if geojson}} + {{#if geojson }} {{else}} - map.panTo(initialPoint, {animate: false}); + map.setZoom(maxZoom, {animate: false}) {{/if}} {{/if}} - {{#if zoom}} - map.setZoom({{ zoom }}, {animate: false}); + {{#if center}} + map.panTo(L.latLng('{{ center }}'.split(',')[1], '{{ center }}'.split(',')[0]), {animate: false}); {{else}} - {{#if geojson }} + {{#if geojson}} {{else}} - map.setZoom(maxZoom, {animate: false}) + map.panTo(initialPoint, {animate: false}); {{/if}} {{/if}} From 5eeb26fe2d271f786167d67ebcf2086967b6889f Mon Sep 17 00:00:00 2001 From: Ives De Bruycker Date: Mon, 23 Jun 2025 15:37:02 +0200 Subject: [PATCH 2/2] Allow passing maxNativeZoom --- src/template.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/template.html b/src/template.html index 0b1567f..64d2628 100644 --- a/src/template.html +++ b/src/template.html @@ -63,6 +63,7 @@ {{/if}} var maxZoom = Number({{maxZoom}}); + var maxNativeZoom = Math.min(Number({{maxNativeZoom}}) || maxZoom, maxZoom); var initialPoint = L.latLng(-34.921779, -57.9524339); var map = new L.Map('map', { @@ -156,6 +157,7 @@ '{{{tileserverUrl}}}', { maxZoom: maxZoom, + maxNativeZoom: maxNativeZoom, fadeAnimation: false } );