From 65d73d56008b63081539ab36e85959954144597e Mon Sep 17 00:00:00 2001 From: Nikolay Korotkiy Date: Mon, 18 Nov 2019 20:28:28 +0300 Subject: [PATCH] Gracefully handle missing tile service bounds in map preview --- handlers/templates/map.html | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/handlers/templates/map.html b/handlers/templates/map.html index 5f2d49c..003cf17 100644 --- a/handlers/templates/map.html +++ b/handlers/templates/map.html @@ -84,10 +84,13 @@ var layer = null; d3.json('./', function(tileJSON) { - var b = tileJSON.bounds; + if (tileJSON.bounds) { + var b = tileJSON.bounds; + + // TODO: optimize and prevent jitter + map.fitBounds([[b[1], b[0]], [b[3], b[2]]]); + } - // TODO: optimize and prevent jitter - map.fitBounds([[b[1], b[0]], [b[3], b[2]]]); if (tileJSON.maxzoom && tileJSON.maxzoom < map.getZoom()){ map.setZoom(tileJSON.maxzoom); }