Add displayDpi option to ol.source.MapGuide constructor
This commit is contained in:
@@ -635,6 +635,7 @@
|
|||||||
/**
|
/**
|
||||||
* @typedef {Object} olx.source.MapGuideOptions
|
* @typedef {Object} olx.source.MapGuideOptions
|
||||||
* @property {string|undefined} url The mapagent url.
|
* @property {string|undefined} url The mapagent url.
|
||||||
|
* @property {number|undefined} displayDpi The display resolution. Default is `96`.
|
||||||
* @property {number|undefined} metersPerUnit The meters-per-unit value. Default is `1`.
|
* @property {number|undefined} metersPerUnit The meters-per-unit value. Default is `1`.
|
||||||
* @property {ol.Extent|undefined} extent Extent.
|
* @property {ol.Extent|undefined} extent Extent.
|
||||||
* @property {boolean|undefined} useOverlay If `true`, will use
|
* @property {boolean|undefined} useOverlay If `true`, will use
|
||||||
|
|||||||
@@ -31,6 +31,13 @@ ol.source.MapGuide = function(options) {
|
|||||||
imageUrlFunction: imageUrlFunction
|
imageUrlFunction: imageUrlFunction
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
this.displayDpi_ = goog.isDef(options.displayDpi) ?
|
||||||
|
options.displayDpi : 96;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {number}
|
* @type {number}
|
||||||
@@ -98,7 +105,7 @@ ol.source.MapGuide.prototype.getScale = function(extent, size) {
|
|||||||
var mcsH = ol.extent.getHeight(extent);
|
var mcsH = ol.extent.getHeight(extent);
|
||||||
var devW = size[0];
|
var devW = size[0];
|
||||||
var devH = size[1];
|
var devH = size[1];
|
||||||
var dpi = 96;
|
var dpi = this.displayDpi_;
|
||||||
var mpu = this.metersPerUnit_;
|
var mpu = this.metersPerUnit_;
|
||||||
var mpp = 0.0254 / dpi;
|
var mpp = 0.0254 / dpi;
|
||||||
if (devH * mcsW > devW * mcsH) {
|
if (devH * mcsW > devW * mcsH) {
|
||||||
@@ -127,7 +134,7 @@ ol.source.MapGuide.prototype.getUrl =
|
|||||||
'LOCALE': 'en',
|
'LOCALE': 'en',
|
||||||
'CLIENTAGENT': 'ol.source.MapGuide source',
|
'CLIENTAGENT': 'ol.source.MapGuide source',
|
||||||
'CLIP': '1',
|
'CLIP': '1',
|
||||||
'SETDISPLAYDPI': 96,
|
'SETDISPLAYDPI': this.displayDpi_,
|
||||||
'SETDISPLAYWIDTH': Math.round(size[0]),
|
'SETDISPLAYWIDTH': Math.round(size[0]),
|
||||||
'SETDISPLAYHEIGHT': Math.round(size[1]),
|
'SETDISPLAYHEIGHT': Math.round(size[1]),
|
||||||
'SETVIEWSCALE': scale,
|
'SETVIEWSCALE': scale,
|
||||||
|
|||||||
Reference in New Issue
Block a user