Add ol.renderer.Layer.snapCenterToPixel
This commit is contained in:
@@ -3,6 +3,7 @@ goog.provide('ol.renderer.Layer');
|
|||||||
goog.require('goog.events');
|
goog.require('goog.events');
|
||||||
goog.require('goog.events.EventType');
|
goog.require('goog.events.EventType');
|
||||||
goog.require('ol.Attribution');
|
goog.require('ol.Attribution');
|
||||||
|
goog.require('ol.Coordinate');
|
||||||
goog.require('ol.FrameState');
|
goog.require('ol.FrameState');
|
||||||
goog.require('ol.Image');
|
goog.require('ol.Image');
|
||||||
goog.require('ol.ImageState');
|
goog.require('ol.ImageState');
|
||||||
@@ -299,3 +300,18 @@ ol.renderer.Layer.prototype.createGetTileIfLoadedFunction =
|
|||||||
return isLoadedFunction(tile) ? tile : null;
|
return isLoadedFunction(tile) ? tile : null;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.Coordinate} center Center.
|
||||||
|
* @param {number} resolution Resolution.
|
||||||
|
* @param {ol.Size} size Size.
|
||||||
|
* @return {ol.Coordinate} Snapped center.
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
ol.renderer.Layer.prototype.snapCenterToPixel =
|
||||||
|
function(center, resolution, size) {
|
||||||
|
return new ol.Coordinate(
|
||||||
|
resolution * (Math.round(center.x / resolution) + (size.width % 2) / 2),
|
||||||
|
resolution * (Math.round(center.y / resolution) + (size.height % 2) / 2));
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user