Merge pull request #818 from twpayne/view2d-properties
View2D properties
This commit is contained in:
@@ -61,10 +61,12 @@ ol.interaction.DragPan.prototype.handleDrag = function(mapBrowserEvent) {
|
|||||||
// FIXME works for View2D only
|
// FIXME works for View2D only
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
goog.asserts.assertInstanceof(view, ol.View2D);
|
goog.asserts.assertInstanceof(view, ol.View2D);
|
||||||
var resolution = view.getResolution();
|
var view2DState = view.getView2DState();
|
||||||
var rotation = view.getRotation();
|
var newCenter = [
|
||||||
var newCenter = [-resolution * this.deltaX, resolution * this.deltaY];
|
-view2DState.resolution * this.deltaX,
|
||||||
ol.coordinate.rotate(newCenter, rotation);
|
view2DState.resolution * this.deltaY
|
||||||
|
];
|
||||||
|
ol.coordinate.rotate(newCenter, view2DState.rotation);
|
||||||
ol.coordinate.add(newCenter, this.startCenter);
|
ol.coordinate.add(newCenter, this.startCenter);
|
||||||
map.requestRenderFrame();
|
map.requestRenderFrame();
|
||||||
view.setCenter(newCenter);
|
view.setCenter(newCenter);
|
||||||
|
|||||||
@@ -64,9 +64,8 @@ ol.interaction.KeyboardPan.prototype.handleMapBrowserEvent =
|
|||||||
// FIXME works for View2D only
|
// FIXME works for View2D only
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
goog.asserts.assertInstanceof(view, ol.View2D);
|
goog.asserts.assertInstanceof(view, ol.View2D);
|
||||||
var resolution = view.getResolution();
|
var view2DState = view.getView2DState();
|
||||||
var rotation = view.getRotation();
|
var mapUnitsDelta = view2DState.resolution * this.delta_;
|
||||||
var mapUnitsDelta = resolution * this.delta_;
|
|
||||||
var deltaX = 0, deltaY = 0;
|
var deltaX = 0, deltaY = 0;
|
||||||
if (keyCode == goog.events.KeyCodes.DOWN) {
|
if (keyCode == goog.events.KeyCodes.DOWN) {
|
||||||
deltaY = -mapUnitsDelta;
|
deltaY = -mapUnitsDelta;
|
||||||
@@ -78,7 +77,7 @@ ol.interaction.KeyboardPan.prototype.handleMapBrowserEvent =
|
|||||||
deltaY = mapUnitsDelta;
|
deltaY = mapUnitsDelta;
|
||||||
}
|
}
|
||||||
var delta = [deltaX, deltaY];
|
var delta = [deltaX, deltaY];
|
||||||
ol.coordinate.rotate(delta, rotation);
|
ol.coordinate.rotate(delta, view2DState.rotation);
|
||||||
ol.interaction.Interaction.pan(
|
ol.interaction.Interaction.pan(
|
||||||
map, view, delta, ol.interaction.KEYBOARD_PAN_DURATION);
|
map, view, delta, ol.interaction.KEYBOARD_PAN_DURATION);
|
||||||
mapBrowserEvent.preventDefault();
|
mapBrowserEvent.preventDefault();
|
||||||
|
|||||||
+8
-9
@@ -89,7 +89,8 @@ ol.View2D = function(opt_options) {
|
|||||||
values[ol.View2DProperty.RESOLUTION] = resolutionConstraint(
|
values[ol.View2DProperty.RESOLUTION] = resolutionConstraint(
|
||||||
this.maxResolution_, options.zoom);
|
this.maxResolution_, options.zoom);
|
||||||
}
|
}
|
||||||
values[ol.View2DProperty.ROTATION] = options.rotation;
|
values[ol.View2DProperty.ROTATION] =
|
||||||
|
goog.isDef(options.rotation) ? options.rotation : 0;
|
||||||
this.setValues(values);
|
this.setValues(values);
|
||||||
};
|
};
|
||||||
goog.inherits(ol.View2D, ol.View);
|
goog.inherits(ol.View2D, ol.View);
|
||||||
@@ -254,12 +255,10 @@ ol.View2D.prototype.getResolutionForValueFunction = function(opt_power) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current rotation of this view.
|
* @inheritDoc
|
||||||
* @return {number} Map rotation.
|
|
||||||
*/
|
*/
|
||||||
ol.View2D.prototype.getRotation = function() {
|
ol.View2D.prototype.getRotation = function() {
|
||||||
return /** @type {number|undefined} */ (
|
return /** @type {number|undefined} */ (this.get(ol.View2DProperty.ROTATION));
|
||||||
this.get(ol.View2DProperty.ROTATION)) || 0;
|
|
||||||
};
|
};
|
||||||
goog.exportProperty(
|
goog.exportProperty(
|
||||||
ol.View2D.prototype,
|
ol.View2D.prototype,
|
||||||
@@ -306,14 +305,14 @@ ol.View2D.prototype.getView2D = function() {
|
|||||||
ol.View2D.prototype.getView2DState = function() {
|
ol.View2D.prototype.getView2DState = function() {
|
||||||
goog.asserts.assert(this.isDef());
|
goog.asserts.assert(this.isDef());
|
||||||
var center = /** @type {ol.Coordinate} */ (this.getCenter());
|
var center = /** @type {ol.Coordinate} */ (this.getCenter());
|
||||||
var projection = /** @type {ol.Projection} */ (this.getProjection());
|
var projection = this.getProjection();
|
||||||
var resolution = /** @type {number} */ (this.getResolution());
|
var resolution = /** @type {number} */ (this.getResolution());
|
||||||
var rotation = /** @type {number} */ (this.getRotation());
|
var rotation = this.getRotation();
|
||||||
return {
|
return {
|
||||||
center: center.slice(),
|
center: center.slice(),
|
||||||
projection: projection,
|
projection: goog.isDef(projection) ? projection : null,
|
||||||
resolution: resolution,
|
resolution: resolution,
|
||||||
rotation: rotation
|
rotation: goog.isDef(rotation) ? rotation : 0
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user