Merge pull request #854 from sxua/master

Detect retina support snippet by Thomas Fuchs
This commit is contained in:
Vladimir Agafonkin 2012-07-30 12:02:08 -07:00
commit b9b967e802
3 changed files with 7 additions and 3 deletions

View File

@ -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
};
}());

View File

@ -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;

View File

@ -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++;