Merge pull request #854 from sxua/master
Detect retina support snippet by Thomas Fuchs
This commit is contained in:
commit
b9b967e802
@ -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
|
||||
};
|
||||
}());
|
||||
|
@ -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;
|
||||
|
@ -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++;
|
||||
|
Loading…
Reference in New Issue
Block a user