MAPG-107 use bigger resolution if the device pixel ratio is big

This commit is contained in:
Bence Pőcze 2020-06-02 21:51:25 +02:00
parent 6acb19ba36
commit 8b9dd0bc32

View File

@ -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', { MapEditor.map = L.map('map', {
attributionControl: false, attributionControl: false,
zoomControl: false zoomControl: false
}); });
var highResData = Util.getHighResData();
L.tileLayer(tileUrl, { L.tileLayer(tileUrl, {
subdomains: '1234',
ppi: highResData.ppi,
tileSize: highResData.tileSize,
zoomOffset: highResData.zoomOffset,
minZoom: 0, minZoom: 0,
maxZoom: 20 maxZoom: 20
}).addTo(MapEditor.map); }).addTo(MapEditor.map);