Add ol.View2D.pan
This commit is contained in:
@@ -16,6 +16,7 @@ goog.require('ol.RotationConstraint');
|
|||||||
goog.require('ol.Size');
|
goog.require('ol.Size');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
goog.require('ol.animation');
|
goog.require('ol.animation');
|
||||||
|
goog.require('ol.easing');
|
||||||
goog.require('ol.projection');
|
goog.require('ol.projection');
|
||||||
|
|
||||||
|
|
||||||
@@ -255,6 +256,26 @@ goog.exportProperty(
|
|||||||
ol.View2D.prototype.setRotation);
|
ol.View2D.prototype.setRotation);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.Map} map Map.
|
||||||
|
* @param {ol.Coordinate} delta Delta.
|
||||||
|
* @param {number=} opt_duration Duration.
|
||||||
|
*/
|
||||||
|
ol.View2D.prototype.pan = function(map, delta, opt_duration) {
|
||||||
|
var currentCenter = this.getCenter();
|
||||||
|
if (goog.isDef(currentCenter) && goog.isDef(opt_duration)) {
|
||||||
|
map.requestRenderFrame();
|
||||||
|
map.addPreRenderFunction(ol.animation.pan({
|
||||||
|
source: currentCenter,
|
||||||
|
duration: opt_duration,
|
||||||
|
easing: ol.easing.linear
|
||||||
|
}));
|
||||||
|
this.setCenter(new ol.Coordinate(
|
||||||
|
currentCenter.x + delta.x, currentCenter.y + delta.y));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Map} map Map.
|
* @param {ol.Map} map Map.
|
||||||
* @param {number|undefined} rotation Rotation.
|
* @param {number|undefined} rotation Rotation.
|
||||||
|
|||||||
Reference in New Issue
Block a user