s/Control/Interaction/, thanks @elemoine
This commit is contained in:
@@ -6,19 +6,19 @@ goog.require('ol.Collection');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.MapProperty');
|
||||
goog.require('ol.Projection');
|
||||
goog.require('ol.control.AltDragRotate');
|
||||
goog.require('ol.control.CenterConstraint');
|
||||
goog.require('ol.control.Constraints');
|
||||
goog.require('ol.control.DblClickZoom');
|
||||
goog.require('ol.control.DragPan');
|
||||
goog.require('ol.control.KeyboardPan');
|
||||
goog.require('ol.control.KeyboardZoom');
|
||||
goog.require('ol.control.MouseWheelZoom');
|
||||
goog.require('ol.control.ResolutionConstraint');
|
||||
goog.require('ol.control.RotationConstraint');
|
||||
goog.require('ol.control.ShiftDragZoom');
|
||||
goog.require('ol.dom');
|
||||
goog.require('ol.dom.Map');
|
||||
goog.require('ol.interaction.AltDragRotate');
|
||||
goog.require('ol.interaction.CenterConstraint');
|
||||
goog.require('ol.interaction.Constraints');
|
||||
goog.require('ol.interaction.DblClickZoom');
|
||||
goog.require('ol.interaction.DragPan');
|
||||
goog.require('ol.interaction.KeyboardPan');
|
||||
goog.require('ol.interaction.KeyboardZoom');
|
||||
goog.require('ol.interaction.MouseWheelZoom');
|
||||
goog.require('ol.interaction.ResolutionConstraint');
|
||||
goog.require('ol.interaction.RotationConstraint');
|
||||
goog.require('ol.interaction.ShiftDragZoom');
|
||||
goog.require('ol.webgl');
|
||||
goog.require('ol.webgl.Map');
|
||||
|
||||
@@ -80,23 +80,24 @@ ol.createMap = function(target, opt_values, opt_rendererHints) {
|
||||
}
|
||||
|
||||
// FIXME this should be a configuration option
|
||||
var centerConstraint = ol.control.CenterConstraint.snapToPixel;
|
||||
var resolutionConstraint = ol.control.ResolutionConstraint.createSnapToPower(
|
||||
Math.exp(Math.log(2) / 8), ol.Projection.EPSG_3857_HALF_SIZE / 128);
|
||||
var rotationConstraint = ol.control.RotationConstraint.none;
|
||||
var constraints = new ol.control.Constraints(
|
||||
var centerConstraint = ol.interaction.CenterConstraint.snapToPixel;
|
||||
var resolutionConstraint =
|
||||
ol.interaction.ResolutionConstraint.createSnapToPower(
|
||||
Math.exp(Math.log(2) / 8), ol.Projection.EPSG_3857_HALF_SIZE / 128);
|
||||
var rotationConstraint = ol.interaction.RotationConstraint.none;
|
||||
var constraints = new ol.interaction.Constraints(
|
||||
centerConstraint, resolutionConstraint, rotationConstraint);
|
||||
|
||||
if (!goog.object.containsKey(values, ol.MapProperty.CONTROLS)) {
|
||||
var controls = new ol.Collection();
|
||||
controls.push(new ol.control.AltDragRotate(constraints));
|
||||
controls.push(new ol.control.DblClickZoom(constraints));
|
||||
controls.push(new ol.control.DragPan(constraints));
|
||||
controls.push(new ol.control.KeyboardPan(constraints, 16));
|
||||
controls.push(new ol.control.KeyboardZoom(constraints));
|
||||
controls.push(new ol.control.MouseWheelZoom(constraints));
|
||||
controls.push(new ol.control.ShiftDragZoom(constraints));
|
||||
values[ol.MapProperty.CONTROLS] = controls;
|
||||
if (!goog.object.containsKey(values, ol.MapProperty.INTERACTIONS)) {
|
||||
var interactions = new ol.Collection();
|
||||
interactions.push(new ol.interaction.AltDragRotate(constraints));
|
||||
interactions.push(new ol.interaction.DblClickZoom(constraints));
|
||||
interactions.push(new ol.interaction.DragPan(constraints));
|
||||
interactions.push(new ol.interaction.KeyboardPan(constraints, 16));
|
||||
interactions.push(new ol.interaction.KeyboardZoom(constraints));
|
||||
interactions.push(new ol.interaction.MouseWheelZoom(constraints));
|
||||
interactions.push(new ol.interaction.ShiftDragZoom(constraints));
|
||||
values[ol.MapProperty.INTERACTIONS] = interactions;
|
||||
}
|
||||
|
||||
if (!goog.object.containsKey(values, ol.MapProperty.LAYERS)) {
|
||||
|
||||
@@ -30,9 +30,9 @@ goog.require('goog.object');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.Collection');
|
||||
goog.require('ol.Color');
|
||||
goog.require('ol.Control');
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Interaction');
|
||||
goog.require('ol.LayerRenderer');
|
||||
goog.require('ol.MapBrowserEvent');
|
||||
goog.require('ol.Object');
|
||||
@@ -48,7 +48,7 @@ goog.require('ol.TransformFunction');
|
||||
ol.MapProperty = {
|
||||
BACKGROUND_COLOR: 'backgroundColor',
|
||||
CENTER: 'center',
|
||||
CONTROLS: 'controls',
|
||||
INTERACTIONS: 'interactions',
|
||||
LAYERS: 'layers',
|
||||
PROJECTION: 'projection',
|
||||
RESOLUTION: 'resolution',
|
||||
@@ -349,18 +349,6 @@ goog.exportProperty(
|
||||
ol.Map.prototype.getCenter);
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.Collection} Controls.
|
||||
*/
|
||||
ol.Map.prototype.getControls = function() {
|
||||
return /** @type {ol.Collection} */ this.get(ol.MapProperty.CONTROLS);
|
||||
};
|
||||
goog.exportProperty(
|
||||
ol.Map.prototype,
|
||||
'getControls',
|
||||
ol.Map.prototype.getControls);
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Pixel} pixel Pixel.
|
||||
* @return {ol.Coordinate|undefined} Coordinate.
|
||||
@@ -396,6 +384,18 @@ ol.Map.prototype.getExtent = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.Collection} Interactions.
|
||||
*/
|
||||
ol.Map.prototype.getInteractions = function() {
|
||||
return /** @type {ol.Collection} */ this.get(ol.MapProperty.INTERACTIONS);
|
||||
};
|
||||
goog.exportProperty(
|
||||
ol.Map.prototype,
|
||||
'getInteractions',
|
||||
ol.Map.prototype.getInteractions);
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Layer} layer Layer.
|
||||
* @protected
|
||||
@@ -581,10 +581,11 @@ ol.Map.prototype.handleBackgroundColorChanged = goog.nullFunction;
|
||||
ol.Map.prototype.handleBrowserEvent = function(browserEvent, opt_type) {
|
||||
var type = opt_type || browserEvent.type;
|
||||
var mapBrowserEvent = new ol.MapBrowserEvent(type, this, browserEvent);
|
||||
var controls = this.getControls();
|
||||
var controlsArray = /** @type {Array.<ol.Control>} */ controls.getArray();
|
||||
goog.array.every(controlsArray, function(control) {
|
||||
control.handleMapBrowserEvent(mapBrowserEvent);
|
||||
var interactions = this.getInteractions();
|
||||
var interactionsArray = /** @type {Array.<ol.Interaction>} */
|
||||
interactions.getArray();
|
||||
goog.array.every(interactionsArray, function(interaction) {
|
||||
interaction.handleMapBrowserEvent(mapBrowserEvent);
|
||||
return !mapBrowserEvent.defaultPrevented;
|
||||
});
|
||||
};
|
||||
@@ -813,15 +814,15 @@ goog.exportProperty(
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Collection} controls Controls.
|
||||
* @param {ol.Collection} interactions Interactions.
|
||||
*/
|
||||
ol.Map.prototype.setControls = function(controls) {
|
||||
this.set(ol.MapProperty.CONTROLS, controls);
|
||||
ol.Map.prototype.setInteractions = function(interactions) {
|
||||
this.set(ol.MapProperty.INTERACTIONS, interactions);
|
||||
};
|
||||
goog.exportProperty(
|
||||
ol.Map.prototype,
|
||||
'setControls',
|
||||
ol.Map.prototype.setControls);
|
||||
'setInteractions',
|
||||
ol.Map.prototype.setInteractions);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user