diff --git a/src/core/Browser.js b/src/core/Browser.js index 3a8c7b58..edd27a6a 100644 --- a/src/core/Browser.js +++ b/src/core/Browser.js @@ -43,6 +43,8 @@ return supported; }()); + var retina = (('devicePixelRatio' in window && window.devicePixelRatio > 1) || ('matchMedia' in window && window.matchMedia("(min-resolution:144dpi)").matches)); + L.Browser = { ua: ua, ie: ie, @@ -66,6 +68,8 @@ mobileWebkit3d: mobile && webkit3d, mobileOpera: mobile && opera, - touch: touch + touch: touch, + + retina: retina }; }()); diff --git a/src/layer/tile/TileLayer.WMS.js b/src/layer/tile/TileLayer.WMS.js index a3b02a37..0984de27 100644 --- a/src/layer/tile/TileLayer.WMS.js +++ b/src/layer/tile/TileLayer.WMS.js @@ -16,7 +16,7 @@ L.TileLayer.WMS = L.TileLayer.extend({ var wmsParams = L.Util.extend({}, this.defaultWmsParams); - if (options.detectRetina && window.devicePixelRatio > 1) { + if (options.detectRetina && L.Browser.retina) { wmsParams.width = wmsParams.height = this.options.tileSize * 2; } else { wmsParams.width = wmsParams.height = this.options.tileSize; diff --git a/src/layer/tile/TileLayer.js b/src/layer/tile/TileLayer.js index d59ae48e..51642687 100644 --- a/src/layer/tile/TileLayer.js +++ b/src/layer/tile/TileLayer.js @@ -31,7 +31,7 @@ L.TileLayer = L.Class.extend({ options = L.Util.setOptions(this, options); // detecting retina displays, adjusting tileSize and zoom levels - if (options.detectRetina && window.devicePixelRatio > 1 && options.maxZoom > 0) { + if (options.detectRetina && L.Browser.retina && options.maxZoom > 0) { options.tileSize = Math.floor(options.tileSize / 2); options.zoomOffset++;