Animate keyboard pan
This commit is contained in:
@@ -9,6 +9,12 @@ goog.require('ol.View2D');
|
|||||||
goog.require('ol.interaction.Interaction');
|
goog.require('ol.interaction.Interaction');
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @define {number} Pan duration.
|
||||||
|
*/
|
||||||
|
ol.interaction.KEYBOARD_PAN_DURATION = 100;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
@@ -60,10 +66,8 @@ ol.interaction.KeyboardPan.prototype.handleMapBrowserEvent =
|
|||||||
} else {
|
} else {
|
||||||
deltaY = mapUnitsDelta;
|
deltaY = mapUnitsDelta;
|
||||||
}
|
}
|
||||||
var oldCenter = view.getCenter();
|
view.pan(map, new ol.Coordinate(deltaX, deltaY),
|
||||||
var newCenter = new ol.Coordinate(
|
ol.interaction.KEYBOARD_PAN_DURATION);
|
||||||
oldCenter.x + deltaX, oldCenter.y + deltaY);
|
|
||||||
view.setCenter(newCenter);
|
|
||||||
keyEvent.preventDefault();
|
keyEvent.preventDefault();
|
||||||
mapBrowserEvent.preventDefault();
|
mapBrowserEvent.preventDefault();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user