From 8b9dd0bc3226f931fab439281b29e5040696e3ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Tue, 2 Jun 2020 21:51:25 +0200 Subject: [PATCH] MAPG-107 use bigger resolution if the device pixel ratio is big --- public/static/js/map_editor.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/public/static/js/map_editor.js b/public/static/js/map_editor.js index 79d631f..3917a28 100644 --- a/public/static/js/map_editor.js +++ b/public/static/js/map_editor.js @@ -70,12 +70,30 @@ } }; + var Util = { + getHighResData: function () { + if (window.devicePixelRatio >= 4) { + return { ppi: 320, tileSize: 128, zoomOffset: 1 }; + } else if (window.devicePixelRatio >= 2) { + return { ppi: 250, tileSize: 256, zoomOffset: 0 }; + } else { + return { ppi: 72, tileSize: 512, zoomOffset: -1 }; + } + } + }; + MapEditor.map = L.map('map', { attributionControl: false, zoomControl: false }); + var highResData = Util.getHighResData(); + L.tileLayer(tileUrl, { + subdomains: '1234', + ppi: highResData.ppi, + tileSize: highResData.tileSize, + zoomOffset: highResData.zoomOffset, minZoom: 0, maxZoom: 20 }).addTo(MapEditor.map);