Use ol.control.CenterConstraint

This commit is contained in:
Tom Payne
2012-08-03 17:33:38 +02:00
parent 1f72319b05
commit c84d5ef9ef
3 changed files with 45 additions and 13 deletions
+5 -2
View File
@@ -6,6 +6,7 @@ goog.require('ol.Collection');
goog.require('ol.Map');
goog.require('ol.MapProperty');
goog.require('ol.Projection');
goog.require('ol.control.CenterConstraint');
goog.require('ol.control.DblClickZoom');
goog.require('ol.control.DragPan');
goog.require('ol.control.KeyboardPan');
@@ -76,6 +77,8 @@ ol.createMap = function(target, opt_values, opt_rendererHints) {
goog.object.extend(values, opt_values);
}
var panFunction = ol.control.CenterConstraint.snapToPixel;
// FIXME this should be a configuration option
var zoomFunction = ol.control.ZoomFunction.createSnapToPower(
2, ol.Projection.EPSG_3857_HALF_SIZE / 128);
@@ -83,8 +86,8 @@ ol.createMap = function(target, opt_values, opt_rendererHints) {
if (!goog.object.containsKey(values, ol.MapProperty.CONTROLS)) {
var controls = new ol.Collection();
controls.push(new ol.control.DblClickZoom(zoomFunction));
controls.push(new ol.control.DragPan());
controls.push(new ol.control.KeyboardPan());
controls.push(new ol.control.DragPan(panFunction));
controls.push(new ol.control.KeyboardPan(panFunction));
controls.push(new ol.control.KeyboardZoom(zoomFunction));
controls.push(new ol.control.MouseWheelZoom(zoomFunction));
controls.push(new ol.control.ShiftDragRotateAndZoom(zoomFunction));