diff --git a/src/objectliterals.jsdoc b/src/objectliterals.jsdoc index df4e7c4e28..375d0ea464 100644 --- a/src/objectliterals.jsdoc +++ b/src/objectliterals.jsdoc @@ -514,6 +514,8 @@ * @property {number|undefined} displayDpi The display resolution. Default is `96`. * @property {number|undefined} metersPerUnit The meters-per-unit value. Default is `1`. * @property {ol.Extent|undefined} extent Extent. + * @property {boolean|undefined} hidpi Use the `ol.Map#devicePixelRatio` value when + * requesting the image from the remote server. Default is `true`. * @property {boolean|undefined} useOverlay If `true`, will use * `GETDYNAMICMAPOVERLAYIMAGE`. * @property {ol.proj.ProjectionLike} projection Projection. @@ -560,6 +562,8 @@ * @property {null|string|undefined} crossOrigin crossOrigin setting for image * requests. * @property {ol.Extent|undefined} extent Extent. + * @property {boolean|undefined} hidpi Use the `ol.Map#devicePixelRatio` value when + * requesting the image from the remote server. Default is `true`. * @property {Object.} params WMS request parameters. At least a * `LAYERS` param is required. `STYLES` is `` by default. `VERSION` is * `1.3.0` by default. `WIDTH`, `HEIGHT`, `BBOX` and `CRS` (`SRS` for WMS diff --git a/src/ol/source/imagewmssource.js b/src/ol/source/imagewmssource.js index 752351fb2a..a52a8b698f 100644 --- a/src/ol/source/imagewmssource.js +++ b/src/ol/source/imagewmssource.js @@ -38,6 +38,12 @@ ol.source.ImageWMS = function(options) { imageUrlFunction: imageUrlFunction }); + /** + * @private + * @type {boolean} + */ + this.hidpi_ = goog.isDef(options.hidpi) ? options.hidpi : true; + /** * @private * @type {ol.Image} @@ -48,8 +54,7 @@ ol.source.ImageWMS = function(options) { * @private * @type {number} */ - this.ratio_ = goog.isDef(options.ratio) ? - options.ratio : 1.5; + this.ratio_ = goog.isDef(options.ratio) ? options.ratio : 1.5; }; goog.inherits(ol.source.ImageWMS, ol.source.Image); @@ -71,6 +76,7 @@ ol.source.ImageWMS.prototype.getParams = function() { ol.source.ImageWMS.prototype.getImage = function(extent, resolution, pixelRatio, projection) { resolution = this.findNearestResolution(resolution); + pixelRatio = this.hidpi_ ? pixelRatio : 1; var image = this.image_; if (!goog.isNull(image) && diff --git a/src/ol/source/mapguidesource.js b/src/ol/source/mapguidesource.js index 2e9ba8aa44..cd831e629d 100644 --- a/src/ol/source/mapguidesource.js +++ b/src/ol/source/mapguidesource.js @@ -31,6 +31,12 @@ ol.source.MapGuide = function(options) { imageUrlFunction: imageUrlFunction }); + /** + * @private + * @type {boolean} + */ + this.hidpi_ = goog.isDef(options.hidpi) ? options.hidpi : true; + /** * @private * @type {number} @@ -74,6 +80,7 @@ goog.inherits(ol.source.MapGuide, ol.source.Image); ol.source.MapGuide.prototype.getImage = function(extent, resolution, pixelRatio, projection) { resolution = this.findNearestResolution(resolution); + pixelRatio = this.hidpi_ ? pixelRatio : 1; var image = this.image_; if (!goog.isNull(image) &&