Add hidpi option to ol.source.ImageWMS and ol.source.MapGuide

This commit is contained in:
Frederic Junod
2013-12-17 09:43:21 +01:00
parent c84782bfc6
commit 8e6b686f3d
3 changed files with 19 additions and 2 deletions

View File

@@ -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.<string,*>} 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

View File

@@ -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) &&

View File

@@ -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) &&