Use ol.control.CenterConstraint
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user