Add ol.renderer.Layer.snapCenterToPixel

This commit is contained in:
Tom Payne
2013-03-10 15:47:31 +01:00
parent 3a1fcdae0f
commit 06463471e1

View File

@@ -3,6 +3,7 @@ goog.provide('ol.renderer.Layer');
goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('ol.Attribution');
goog.require('ol.Coordinate');
goog.require('ol.FrameState');
goog.require('ol.Image');
goog.require('ol.ImageState');
@@ -299,3 +300,18 @@ ol.renderer.Layer.prototype.createGetTileIfLoadedFunction =
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));
};