Transformed

This commit is contained in:
Tim Schaub
2017-12-11 16:29:33 -07:00
parent 1cdb6a66f0
commit 7f47883c48
737 changed files with 22216 additions and 21609 deletions

View File

@@ -1,9 +1,9 @@
goog.provide('ol.interaction.DoubleClickZoom');
goog.require('ol');
goog.require('ol.MapBrowserEventType');
goog.require('ol.interaction.Interaction');
/**
* @module ol/interaction/DoubleClickZoom
*/
import _ol_ from '../index.js';
import _ol_MapBrowserEventType_ from '../MapBrowserEventType.js';
import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
/**
* @classdesc
@@ -14,7 +14,7 @@ goog.require('ol.interaction.Interaction');
* @param {olx.interaction.DoubleClickZoomOptions=} opt_options Options.
* @api
*/
ol.interaction.DoubleClickZoom = function(opt_options) {
var _ol_interaction_DoubleClickZoom_ = function(opt_options) {
var options = opt_options ? opt_options : {};
@@ -24,8 +24,8 @@ ol.interaction.DoubleClickZoom = function(opt_options) {
*/
this.delta_ = options.delta ? options.delta : 1;
ol.interaction.Interaction.call(this, {
handleEvent: ol.interaction.DoubleClickZoom.handleEvent
_ol_interaction_Interaction_.call(this, {
handleEvent: _ol_interaction_DoubleClickZoom_.handleEvent
});
/**
@@ -35,7 +35,8 @@ ol.interaction.DoubleClickZoom = function(opt_options) {
this.duration_ = options.duration !== undefined ? options.duration : 250;
};
ol.inherits(ol.interaction.DoubleClickZoom, ol.interaction.Interaction);
_ol_.inherits(_ol_interaction_DoubleClickZoom_, _ol_interaction_Interaction_);
/**
@@ -46,18 +47,19 @@ ol.inherits(ol.interaction.DoubleClickZoom, ol.interaction.Interaction);
* @this {ol.interaction.DoubleClickZoom}
* @api
*/
ol.interaction.DoubleClickZoom.handleEvent = function(mapBrowserEvent) {
_ol_interaction_DoubleClickZoom_.handleEvent = function(mapBrowserEvent) {
var stopEvent = false;
var browserEvent = mapBrowserEvent.originalEvent;
if (mapBrowserEvent.type == ol.MapBrowserEventType.DBLCLICK) {
if (mapBrowserEvent.type == _ol_MapBrowserEventType_.DBLCLICK) {
var map = mapBrowserEvent.map;
var anchor = mapBrowserEvent.coordinate;
var delta = browserEvent.shiftKey ? -this.delta_ : this.delta_;
var view = map.getView();
ol.interaction.Interaction.zoomByDelta(
_ol_interaction_Interaction_.zoomByDelta(
view, delta, anchor, this.duration_);
mapBrowserEvent.preventDefault();
stopEvent = true;
}
return !stopEvent;
};
export default _ol_interaction_DoubleClickZoom_;

View File

@@ -1,15 +1,15 @@
/**
* @module ol/interaction/DragAndDrop
*/
// FIXME should handle all geo-referenced data, not just vector data
goog.provide('ol.interaction.DragAndDrop');
goog.require('ol');
goog.require('ol.functions');
goog.require('ol.events');
goog.require('ol.events.Event');
goog.require('ol.events.EventType');
goog.require('ol.interaction.Interaction');
goog.require('ol.proj');
import _ol_ from '../index.js';
import _ol_functions_ from '../functions.js';
import _ol_events_ from '../events.js';
import _ol_events_Event_ from '../events/Event.js';
import _ol_events_EventType_ from '../events/EventType.js';
import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
import _ol_proj_ from '../proj.js';
/**
* @classdesc
@@ -21,12 +21,12 @@ goog.require('ol.proj');
* @param {olx.interaction.DragAndDropOptions=} opt_options Options.
* @api
*/
ol.interaction.DragAndDrop = function(opt_options) {
var _ol_interaction_DragAndDrop_ = function(opt_options) {
var options = opt_options ? opt_options : {};
ol.interaction.Interaction.call(this, {
handleEvent: ol.interaction.DragAndDrop.handleEvent
_ol_interaction_Interaction_.call(this, {
handleEvent: _ol_interaction_DragAndDrop_.handleEvent
});
/**
@@ -41,7 +41,7 @@ ol.interaction.DragAndDrop = function(opt_options) {
* @type {ol.proj.Projection}
*/
this.projection_ = options.projection ?
ol.proj.get(options.projection) : null;
_ol_proj_.get(options.projection) : null;
/**
* @private
@@ -62,7 +62,8 @@ ol.interaction.DragAndDrop = function(opt_options) {
this.target = options.target ? options.target : null;
};
ol.inherits(ol.interaction.DragAndDrop, ol.interaction.Interaction);
_ol_.inherits(_ol_interaction_DragAndDrop_, _ol_interaction_Interaction_);
/**
@@ -70,13 +71,13 @@ ol.inherits(ol.interaction.DragAndDrop, ol.interaction.Interaction);
* @this {ol.interaction.DragAndDrop}
* @private
*/
ol.interaction.DragAndDrop.handleDrop_ = function(event) {
_ol_interaction_DragAndDrop_.handleDrop_ = function(event) {
var files = event.dataTransfer.files;
var i, ii, file;
for (i = 0, ii = files.length; i < ii; ++i) {
file = files.item(i);
var reader = new FileReader();
reader.addEventListener(ol.events.EventType.LOAD,
reader.addEventListener(_ol_events_EventType_.LOAD,
this.handleResult_.bind(this, file));
reader.readAsText(file);
}
@@ -87,7 +88,7 @@ ol.interaction.DragAndDrop.handleDrop_ = function(event) {
* @param {Event} event Event.
* @private
*/
ol.interaction.DragAndDrop.handleStop_ = function(event) {
_ol_interaction_DragAndDrop_.handleStop_ = function(event) {
event.stopPropagation();
event.preventDefault();
event.dataTransfer.dropEffect = 'copy';
@@ -99,7 +100,7 @@ ol.interaction.DragAndDrop.handleStop_ = function(event) {
* @param {Event} event Load event.
* @private
*/
ol.interaction.DragAndDrop.prototype.handleResult_ = function(file, event) {
_ol_interaction_DragAndDrop_.prototype.handleResult_ = function(file, event) {
var result = event.target.result;
var map = this.getMap();
var projection = this.projection_;
@@ -133,8 +134,8 @@ ol.interaction.DragAndDrop.prototype.handleResult_ = function(file, event) {
this.source_.addFeatures(features);
}
this.dispatchEvent(
new ol.interaction.DragAndDrop.Event(
ol.interaction.DragAndDrop.EventType_.ADD_FEATURES, file,
new _ol_interaction_DragAndDrop_.Event(
_ol_interaction_DragAndDrop_.EventType_.ADD_FEATURES, file,
features, projection));
};
@@ -147,25 +148,25 @@ ol.interaction.DragAndDrop.prototype.handleResult_ = function(file, event) {
* @this {ol.interaction.DragAndDrop}
* @api
*/
ol.interaction.DragAndDrop.handleEvent = ol.functions.TRUE;
_ol_interaction_DragAndDrop_.handleEvent = _ol_functions_.TRUE;
/**
* @private
*/
ol.interaction.DragAndDrop.prototype.registerListeners_ = function() {
_ol_interaction_DragAndDrop_.prototype.registerListeners_ = function() {
var map = this.getMap();
if (map) {
var dropArea = this.target ? this.target : map.getViewport();
this.dropListenKeys_ = [
ol.events.listen(dropArea, ol.events.EventType.DROP,
ol.interaction.DragAndDrop.handleDrop_, this),
ol.events.listen(dropArea, ol.events.EventType.DRAGENTER,
ol.interaction.DragAndDrop.handleStop_, this),
ol.events.listen(dropArea, ol.events.EventType.DRAGOVER,
ol.interaction.DragAndDrop.handleStop_, this),
ol.events.listen(dropArea, ol.events.EventType.DROP,
ol.interaction.DragAndDrop.handleStop_, this)
_ol_events_.listen(dropArea, _ol_events_EventType_.DROP,
_ol_interaction_DragAndDrop_.handleDrop_, this),
_ol_events_.listen(dropArea, _ol_events_EventType_.DRAGENTER,
_ol_interaction_DragAndDrop_.handleStop_, this),
_ol_events_.listen(dropArea, _ol_events_EventType_.DRAGOVER,
_ol_interaction_DragAndDrop_.handleStop_, this),
_ol_events_.listen(dropArea, _ol_events_EventType_.DROP,
_ol_interaction_DragAndDrop_.handleStop_, this)
];
}
};
@@ -174,8 +175,8 @@ ol.interaction.DragAndDrop.prototype.registerListeners_ = function() {
/**
* @inheritDoc
*/
ol.interaction.DragAndDrop.prototype.setActive = function(active) {
ol.interaction.Interaction.prototype.setActive.call(this, active);
_ol_interaction_DragAndDrop_.prototype.setActive = function(active) {
_ol_interaction_Interaction_.prototype.setActive.call(this, active);
if (active) {
this.registerListeners_();
} else {
@@ -187,9 +188,9 @@ ol.interaction.DragAndDrop.prototype.setActive = function(active) {
/**
* @inheritDoc
*/
ol.interaction.DragAndDrop.prototype.setMap = function(map) {
_ol_interaction_DragAndDrop_.prototype.setMap = function(map) {
this.unregisterListeners_();
ol.interaction.Interaction.prototype.setMap.call(this, map);
_ol_interaction_Interaction_.prototype.setMap.call(this, map);
if (this.getActive()) {
this.registerListeners_();
}
@@ -203,7 +204,7 @@ ol.interaction.DragAndDrop.prototype.setMap = function(map) {
* @private
* @return {Array.<ol.Feature>} Features.
*/
ol.interaction.DragAndDrop.prototype.tryReadFeatures_ = function(format, text, options) {
_ol_interaction_DragAndDrop_.prototype.tryReadFeatures_ = function(format, text, options) {
try {
return format.readFeatures(text, options);
} catch (e) {
@@ -215,9 +216,9 @@ ol.interaction.DragAndDrop.prototype.tryReadFeatures_ = function(format, text, o
/**
* @private
*/
ol.interaction.DragAndDrop.prototype.unregisterListeners_ = function() {
_ol_interaction_DragAndDrop_.prototype.unregisterListeners_ = function() {
if (this.dropListenKeys_) {
this.dropListenKeys_.forEach(ol.events.unlistenByKey);
this.dropListenKeys_.forEach(_ol_events_.unlistenByKey);
this.dropListenKeys_ = null;
}
};
@@ -227,7 +228,7 @@ ol.interaction.DragAndDrop.prototype.unregisterListeners_ = function() {
* @enum {string}
* @private
*/
ol.interaction.DragAndDrop.EventType_ = {
_ol_interaction_DragAndDrop_.EventType_ = {
/**
* Triggered when features are added
* @event ol.interaction.DragAndDrop.Event#addfeatures
@@ -250,9 +251,9 @@ ol.interaction.DragAndDrop.EventType_ = {
* @param {Array.<ol.Feature>=} opt_features Features.
* @param {ol.proj.Projection=} opt_projection Projection.
*/
ol.interaction.DragAndDrop.Event = function(type, file, opt_features, opt_projection) {
_ol_interaction_DragAndDrop_.Event = function(type, file, opt_features, opt_projection) {
ol.events.Event.call(this, type);
_ol_events_Event_.call(this, type);
/**
* The features parsed from dropped data.
@@ -276,4 +277,5 @@ ol.interaction.DragAndDrop.Event = function(type, file, opt_features, opt_projec
this.projection = opt_projection;
};
ol.inherits(ol.interaction.DragAndDrop.Event, ol.events.Event);
_ol_.inherits(_ol_interaction_DragAndDrop_.Event, _ol_events_Event_);
export default _ol_interaction_DragAndDrop_;

View File

@@ -1,12 +1,12 @@
/**
* @module ol/interaction/DragBox
*/
// FIXME draw drag box
goog.provide('ol.interaction.DragBox');
goog.require('ol.events.Event');
goog.require('ol');
goog.require('ol.events.condition');
goog.require('ol.interaction.Pointer');
goog.require('ol.render.Box');
import _ol_events_Event_ from '../events/Event.js';
import _ol_ from '../index.js';
import _ol_events_condition_ from '../events/condition.js';
import _ol_interaction_Pointer_ from '../interaction/Pointer.js';
import _ol_render_Box_ from '../render/Box.js';
/**
* @classdesc
@@ -25,12 +25,12 @@ goog.require('ol.render.Box');
* @param {olx.interaction.DragBoxOptions=} opt_options Options.
* @api
*/
ol.interaction.DragBox = function(opt_options) {
var _ol_interaction_DragBox_ = function(opt_options) {
ol.interaction.Pointer.call(this, {
handleDownEvent: ol.interaction.DragBox.handleDownEvent_,
handleDragEvent: ol.interaction.DragBox.handleDragEvent_,
handleUpEvent: ol.interaction.DragBox.handleUpEvent_
_ol_interaction_Pointer_.call(this, {
handleDownEvent: _ol_interaction_DragBox_.handleDownEvent_,
handleDragEvent: _ol_interaction_DragBox_.handleDragEvent_,
handleUpEvent: _ol_interaction_DragBox_.handleUpEvent_
});
var options = opt_options ? opt_options : {};
@@ -39,7 +39,7 @@ ol.interaction.DragBox = function(opt_options) {
* @type {ol.render.Box}
* @private
*/
this.box_ = new ol.render.Box(options.className || 'ol-dragbox');
this.box_ = new _ol_render_Box_(options.className || 'ol-dragbox');
/**
* @type {number}
@@ -58,16 +58,17 @@ ol.interaction.DragBox = function(opt_options) {
* @type {ol.EventsConditionType}
*/
this.condition_ = options.condition ?
options.condition : ol.events.condition.always;
options.condition : _ol_events_condition_.always;
/**
* @private
* @type {ol.DragBoxEndConditionType}
*/
this.boxEndCondition_ = options.boxEndCondition ?
options.boxEndCondition : ol.interaction.DragBox.defaultBoxEndCondition;
options.boxEndCondition : _ol_interaction_DragBox_.defaultBoxEndCondition;
};
ol.inherits(ol.interaction.DragBox, ol.interaction.Pointer);
_ol_.inherits(_ol_interaction_DragBox_, _ol_interaction_Pointer_);
/**
@@ -80,7 +81,7 @@ ol.inherits(ol.interaction.DragBox, ol.interaction.Pointer);
* @return {boolean} Whether or not the boxend condition should be fired.
* @this {ol.interaction.DragBox}
*/
ol.interaction.DragBox.defaultBoxEndCondition = function(mapBrowserEvent, startPixel, endPixel) {
_ol_interaction_DragBox_.defaultBoxEndCondition = function(mapBrowserEvent, startPixel, endPixel) {
var width = endPixel[0] - startPixel[0];
var height = endPixel[1] - startPixel[1];
return width * width + height * height >= this.minArea_;
@@ -92,14 +93,14 @@ ol.interaction.DragBox.defaultBoxEndCondition = function(mapBrowserEvent, startP
* @this {ol.interaction.DragBox}
* @private
*/
ol.interaction.DragBox.handleDragEvent_ = function(mapBrowserEvent) {
if (!ol.events.condition.mouseOnly(mapBrowserEvent)) {
_ol_interaction_DragBox_.handleDragEvent_ = function(mapBrowserEvent) {
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) {
return;
}
this.box_.setPixels(this.startPixel_, mapBrowserEvent.pixel);
this.dispatchEvent(new ol.interaction.DragBox.Event(ol.interaction.DragBox.EventType_.BOXDRAG,
this.dispatchEvent(new _ol_interaction_DragBox_.Event(_ol_interaction_DragBox_.EventType_.BOXDRAG,
mapBrowserEvent.coordinate, mapBrowserEvent));
};
@@ -109,7 +110,7 @@ ol.interaction.DragBox.handleDragEvent_ = function(mapBrowserEvent) {
* @return {ol.geom.Polygon} Geometry.
* @api
*/
ol.interaction.DragBox.prototype.getGeometry = function() {
_ol_interaction_DragBox_.prototype.getGeometry = function() {
return this.box_.getGeometry();
};
@@ -120,7 +121,7 @@ ol.interaction.DragBox.prototype.getGeometry = function() {
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
* @protected
*/
ol.interaction.DragBox.prototype.onBoxEnd = ol.nullFunction;
_ol_interaction_DragBox_.prototype.onBoxEnd = _ol_.nullFunction;
/**
@@ -129,8 +130,8 @@ ol.interaction.DragBox.prototype.onBoxEnd = ol.nullFunction;
* @this {ol.interaction.DragBox}
* @private
*/
ol.interaction.DragBox.handleUpEvent_ = function(mapBrowserEvent) {
if (!ol.events.condition.mouseOnly(mapBrowserEvent)) {
_ol_interaction_DragBox_.handleUpEvent_ = function(mapBrowserEvent) {
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) {
return true;
}
@@ -139,7 +140,7 @@ ol.interaction.DragBox.handleUpEvent_ = function(mapBrowserEvent) {
if (this.boxEndCondition_(mapBrowserEvent,
this.startPixel_, mapBrowserEvent.pixel)) {
this.onBoxEnd(mapBrowserEvent);
this.dispatchEvent(new ol.interaction.DragBox.Event(ol.interaction.DragBox.EventType_.BOXEND,
this.dispatchEvent(new _ol_interaction_DragBox_.Event(_ol_interaction_DragBox_.EventType_.BOXEND,
mapBrowserEvent.coordinate, mapBrowserEvent));
}
return false;
@@ -152,17 +153,17 @@ ol.interaction.DragBox.handleUpEvent_ = function(mapBrowserEvent) {
* @this {ol.interaction.DragBox}
* @private
*/
ol.interaction.DragBox.handleDownEvent_ = function(mapBrowserEvent) {
if (!ol.events.condition.mouseOnly(mapBrowserEvent)) {
_ol_interaction_DragBox_.handleDownEvent_ = function(mapBrowserEvent) {
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) {
return false;
}
if (ol.events.condition.mouseActionButton(mapBrowserEvent) &&
if (_ol_events_condition_.mouseActionButton(mapBrowserEvent) &&
this.condition_(mapBrowserEvent)) {
this.startPixel_ = mapBrowserEvent.pixel;
this.box_.setMap(mapBrowserEvent.map);
this.box_.setPixels(this.startPixel_, this.startPixel_);
this.dispatchEvent(new ol.interaction.DragBox.Event(ol.interaction.DragBox.EventType_.BOXSTART,
this.dispatchEvent(new _ol_interaction_DragBox_.Event(_ol_interaction_DragBox_.EventType_.BOXSTART,
mapBrowserEvent.coordinate, mapBrowserEvent));
return true;
} else {
@@ -175,7 +176,7 @@ ol.interaction.DragBox.handleDownEvent_ = function(mapBrowserEvent) {
* @enum {string}
* @private
*/
ol.interaction.DragBox.EventType_ = {
_ol_interaction_DragBox_.EventType_ = {
/**
* Triggered upon drag box start.
* @event ol.interaction.DragBox.Event#boxstart
@@ -211,8 +212,8 @@ ol.interaction.DragBox.EventType_ = {
* @constructor
* @implements {oli.DragBoxEvent}
*/
ol.interaction.DragBox.Event = function(type, coordinate, mapBrowserEvent) {
ol.events.Event.call(this, type);
_ol_interaction_DragBox_.Event = function(type, coordinate, mapBrowserEvent) {
_ol_events_Event_.call(this, type);
/**
* The coordinate of the drag event.
@@ -230,4 +231,5 @@ ol.interaction.DragBox.Event = function(type, coordinate, mapBrowserEvent) {
this.mapBrowserEvent = mapBrowserEvent;
};
ol.inherits(ol.interaction.DragBox.Event, ol.events.Event);
_ol_.inherits(_ol_interaction_DragBox_.Event, _ol_events_Event_);
export default _ol_interaction_DragBox_;

View File

@@ -1,13 +1,13 @@
goog.provide('ol.interaction.DragPan');
goog.require('ol');
goog.require('ol.ViewHint');
goog.require('ol.coordinate');
goog.require('ol.easing');
goog.require('ol.events.condition');
goog.require('ol.functions');
goog.require('ol.interaction.Pointer');
/**
* @module ol/interaction/DragPan
*/
import _ol_ from '../index.js';
import _ol_ViewHint_ from '../ViewHint.js';
import _ol_coordinate_ from '../coordinate.js';
import _ol_easing_ from '../easing.js';
import _ol_events_condition_ from '../events/condition.js';
import _ol_functions_ from '../functions.js';
import _ol_interaction_Pointer_ from '../interaction/Pointer.js';
/**
* @classdesc
@@ -18,12 +18,12 @@ goog.require('ol.interaction.Pointer');
* @param {olx.interaction.DragPanOptions=} opt_options Options.
* @api
*/
ol.interaction.DragPan = function(opt_options) {
var _ol_interaction_DragPan_ = function(opt_options) {
ol.interaction.Pointer.call(this, {
handleDownEvent: ol.interaction.DragPan.handleDownEvent_,
handleDragEvent: ol.interaction.DragPan.handleDragEvent_,
handleUpEvent: ol.interaction.DragPan.handleUpEvent_
_ol_interaction_Pointer_.call(this, {
handleDownEvent: _ol_interaction_DragPan_.handleDownEvent_,
handleDragEvent: _ol_interaction_DragPan_.handleDragEvent_,
handleUpEvent: _ol_interaction_DragPan_.handleUpEvent_
});
var options = opt_options ? opt_options : {};
@@ -49,7 +49,7 @@ ol.interaction.DragPan = function(opt_options) {
* @type {ol.EventsConditionType}
*/
this.condition_ = options.condition ?
options.condition : ol.events.condition.noModifierKeys;
options.condition : _ol_events_condition_.noModifierKeys;
/**
* @private
@@ -58,7 +58,8 @@ ol.interaction.DragPan = function(opt_options) {
this.noKinetic_ = false;
};
ol.inherits(ol.interaction.DragPan, ol.interaction.Pointer);
_ol_.inherits(_ol_interaction_DragPan_, _ol_interaction_Pointer_);
/**
@@ -66,10 +67,10 @@ ol.inherits(ol.interaction.DragPan, ol.interaction.Pointer);
* @this {ol.interaction.DragPan}
* @private
*/
ol.interaction.DragPan.handleDragEvent_ = function(mapBrowserEvent) {
_ol_interaction_DragPan_.handleDragEvent_ = function(mapBrowserEvent) {
var targetPointers = this.targetPointers;
var centroid =
ol.interaction.Pointer.centroid(targetPointers);
_ol_interaction_Pointer_.centroid(targetPointers);
if (targetPointers.length == this.lastPointersCount_) {
if (this.kinetic_) {
this.kinetic_.update(centroid[0], centroid[1]);
@@ -81,9 +82,9 @@ ol.interaction.DragPan.handleDragEvent_ = function(mapBrowserEvent) {
var view = map.getView();
var viewState = view.getState();
var center = [deltaX, deltaY];
ol.coordinate.scale(center, viewState.resolution);
ol.coordinate.rotate(center, viewState.rotation);
ol.coordinate.add(center, viewState.center);
_ol_coordinate_.scale(center, viewState.resolution);
_ol_coordinate_.rotate(center, viewState.rotation);
_ol_coordinate_.add(center, viewState.center);
center = view.constrainCenter(center);
view.setCenter(center);
}
@@ -103,7 +104,7 @@ ol.interaction.DragPan.handleDragEvent_ = function(mapBrowserEvent) {
* @this {ol.interaction.DragPan}
* @private
*/
ol.interaction.DragPan.handleUpEvent_ = function(mapBrowserEvent) {
_ol_interaction_DragPan_.handleUpEvent_ = function(mapBrowserEvent) {
var map = mapBrowserEvent.map;
var view = map.getView();
if (this.targetPointers.length === 0) {
@@ -119,10 +120,10 @@ ol.interaction.DragPan.handleUpEvent_ = function(mapBrowserEvent) {
view.animate({
center: view.constrainCenter(dest),
duration: 500,
easing: ol.easing.easeOut
easing: _ol_easing_.easeOut
});
}
view.setHint(ol.ViewHint.INTERACTING, -1);
view.setHint(_ol_ViewHint_.INTERACTING, -1);
return false;
} else {
if (this.kinetic_) {
@@ -142,13 +143,13 @@ ol.interaction.DragPan.handleUpEvent_ = function(mapBrowserEvent) {
* @this {ol.interaction.DragPan}
* @private
*/
ol.interaction.DragPan.handleDownEvent_ = function(mapBrowserEvent) {
_ol_interaction_DragPan_.handleDownEvent_ = function(mapBrowserEvent) {
if (this.targetPointers.length > 0 && this.condition_(mapBrowserEvent)) {
var map = mapBrowserEvent.map;
var view = map.getView();
this.lastCentroid = null;
if (!this.handlingDownUpSequence) {
view.setHint(ol.ViewHint.INTERACTING, 1);
view.setHint(_ol_ViewHint_.INTERACTING, 1);
}
// stop any current animation
if (view.getAnimating()) {
@@ -170,4 +171,5 @@ ol.interaction.DragPan.handleDownEvent_ = function(mapBrowserEvent) {
/**
* @inheritDoc
*/
ol.interaction.DragPan.prototype.shouldStopEvent = ol.functions.FALSE;
_ol_interaction_DragPan_.prototype.shouldStopEvent = _ol_functions_.FALSE;
export default _ol_interaction_DragPan_;

View File

@@ -1,13 +1,13 @@
goog.provide('ol.interaction.DragRotate');
goog.require('ol');
goog.require('ol.RotationConstraint');
goog.require('ol.ViewHint');
goog.require('ol.events.condition');
goog.require('ol.functions');
goog.require('ol.interaction.Interaction');
goog.require('ol.interaction.Pointer');
/**
* @module ol/interaction/DragRotate
*/
import _ol_ from '../index.js';
import _ol_RotationConstraint_ from '../RotationConstraint.js';
import _ol_ViewHint_ from '../ViewHint.js';
import _ol_events_condition_ from '../events/condition.js';
import _ol_functions_ from '../functions.js';
import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
import _ol_interaction_Pointer_ from '../interaction/Pointer.js';
/**
* @classdesc
@@ -22,14 +22,14 @@ goog.require('ol.interaction.Pointer');
* @param {olx.interaction.DragRotateOptions=} opt_options Options.
* @api
*/
ol.interaction.DragRotate = function(opt_options) {
var _ol_interaction_DragRotate_ = function(opt_options) {
var options = opt_options ? opt_options : {};
ol.interaction.Pointer.call(this, {
handleDownEvent: ol.interaction.DragRotate.handleDownEvent_,
handleDragEvent: ol.interaction.DragRotate.handleDragEvent_,
handleUpEvent: ol.interaction.DragRotate.handleUpEvent_
_ol_interaction_Pointer_.call(this, {
handleDownEvent: _ol_interaction_DragRotate_.handleDownEvent_,
handleDragEvent: _ol_interaction_DragRotate_.handleDragEvent_,
handleUpEvent: _ol_interaction_DragRotate_.handleUpEvent_
});
/**
@@ -37,7 +37,7 @@ ol.interaction.DragRotate = function(opt_options) {
* @type {ol.EventsConditionType}
*/
this.condition_ = options.condition ?
options.condition : ol.events.condition.altShiftKeysOnly;
options.condition : _ol_events_condition_.altShiftKeysOnly;
/**
* @private
@@ -51,7 +51,8 @@ ol.interaction.DragRotate = function(opt_options) {
*/
this.duration_ = options.duration !== undefined ? options.duration : 250;
};
ol.inherits(ol.interaction.DragRotate, ol.interaction.Pointer);
_ol_.inherits(_ol_interaction_DragRotate_, _ol_interaction_Pointer_);
/**
@@ -59,14 +60,14 @@ ol.inherits(ol.interaction.DragRotate, ol.interaction.Pointer);
* @this {ol.interaction.DragRotate}
* @private
*/
ol.interaction.DragRotate.handleDragEvent_ = function(mapBrowserEvent) {
if (!ol.events.condition.mouseOnly(mapBrowserEvent)) {
_ol_interaction_DragRotate_.handleDragEvent_ = function(mapBrowserEvent) {
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) {
return;
}
var map = mapBrowserEvent.map;
var view = map.getView();
if (view.getConstraints().rotation === ol.RotationConstraint.disable) {
if (view.getConstraints().rotation === _ol_RotationConstraint_.disable) {
return;
}
var size = map.getSize();
@@ -76,7 +77,7 @@ ol.interaction.DragRotate.handleDragEvent_ = function(mapBrowserEvent) {
if (this.lastAngle_ !== undefined) {
var delta = theta - this.lastAngle_;
var rotation = view.getRotation();
ol.interaction.Interaction.rotateWithoutConstraints(
_ol_interaction_Interaction_.rotateWithoutConstraints(
view, rotation - delta);
}
this.lastAngle_ = theta;
@@ -89,16 +90,16 @@ ol.interaction.DragRotate.handleDragEvent_ = function(mapBrowserEvent) {
* @this {ol.interaction.DragRotate}
* @private
*/
ol.interaction.DragRotate.handleUpEvent_ = function(mapBrowserEvent) {
if (!ol.events.condition.mouseOnly(mapBrowserEvent)) {
_ol_interaction_DragRotate_.handleUpEvent_ = function(mapBrowserEvent) {
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) {
return true;
}
var map = mapBrowserEvent.map;
var view = map.getView();
view.setHint(ol.ViewHint.INTERACTING, -1);
view.setHint(_ol_ViewHint_.INTERACTING, -1);
var rotation = view.getRotation();
ol.interaction.Interaction.rotate(view, rotation,
_ol_interaction_Interaction_.rotate(view, rotation,
undefined, this.duration_);
return false;
};
@@ -110,15 +111,15 @@ ol.interaction.DragRotate.handleUpEvent_ = function(mapBrowserEvent) {
* @this {ol.interaction.DragRotate}
* @private
*/
ol.interaction.DragRotate.handleDownEvent_ = function(mapBrowserEvent) {
if (!ol.events.condition.mouseOnly(mapBrowserEvent)) {
_ol_interaction_DragRotate_.handleDownEvent_ = function(mapBrowserEvent) {
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) {
return false;
}
if (ol.events.condition.mouseActionButton(mapBrowserEvent) &&
if (_ol_events_condition_.mouseActionButton(mapBrowserEvent) &&
this.condition_(mapBrowserEvent)) {
var map = mapBrowserEvent.map;
map.getView().setHint(ol.ViewHint.INTERACTING, 1);
map.getView().setHint(_ol_ViewHint_.INTERACTING, 1);
this.lastAngle_ = undefined;
return true;
} else {
@@ -130,4 +131,5 @@ ol.interaction.DragRotate.handleDownEvent_ = function(mapBrowserEvent) {
/**
* @inheritDoc
*/
ol.interaction.DragRotate.prototype.shouldStopEvent = ol.functions.FALSE;
_ol_interaction_DragRotate_.prototype.shouldStopEvent = _ol_functions_.FALSE;
export default _ol_interaction_DragRotate_;

View File

@@ -1,12 +1,12 @@
goog.provide('ol.interaction.DragRotateAndZoom');
goog.require('ol');
goog.require('ol.RotationConstraint');
goog.require('ol.ViewHint');
goog.require('ol.events.condition');
goog.require('ol.interaction.Interaction');
goog.require('ol.interaction.Pointer');
/**
* @module ol/interaction/DragRotateAndZoom
*/
import _ol_ from '../index.js';
import _ol_RotationConstraint_ from '../RotationConstraint.js';
import _ol_ViewHint_ from '../ViewHint.js';
import _ol_events_condition_ from '../events/condition.js';
import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
import _ol_interaction_Pointer_ from '../interaction/Pointer.js';
/**
* @classdesc
@@ -23,14 +23,14 @@ goog.require('ol.interaction.Pointer');
* @param {olx.interaction.DragRotateAndZoomOptions=} opt_options Options.
* @api
*/
ol.interaction.DragRotateAndZoom = function(opt_options) {
var _ol_interaction_DragRotateAndZoom_ = function(opt_options) {
var options = opt_options ? opt_options : {};
ol.interaction.Pointer.call(this, {
handleDownEvent: ol.interaction.DragRotateAndZoom.handleDownEvent_,
handleDragEvent: ol.interaction.DragRotateAndZoom.handleDragEvent_,
handleUpEvent: ol.interaction.DragRotateAndZoom.handleUpEvent_
_ol_interaction_Pointer_.call(this, {
handleDownEvent: _ol_interaction_DragRotateAndZoom_.handleDownEvent_,
handleDragEvent: _ol_interaction_DragRotateAndZoom_.handleDragEvent_,
handleUpEvent: _ol_interaction_DragRotateAndZoom_.handleUpEvent_
});
/**
@@ -38,7 +38,7 @@ ol.interaction.DragRotateAndZoom = function(opt_options) {
* @type {ol.EventsConditionType}
*/
this.condition_ = options.condition ?
options.condition : ol.events.condition.shiftKeyOnly;
options.condition : _ol_events_condition_.shiftKeyOnly;
/**
* @private
@@ -65,7 +65,8 @@ ol.interaction.DragRotateAndZoom = function(opt_options) {
this.duration_ = options.duration !== undefined ? options.duration : 400;
};
ol.inherits(ol.interaction.DragRotateAndZoom, ol.interaction.Pointer);
_ol_.inherits(_ol_interaction_DragRotateAndZoom_, _ol_interaction_Pointer_);
/**
@@ -73,8 +74,8 @@ ol.inherits(ol.interaction.DragRotateAndZoom, ol.interaction.Pointer);
* @this {ol.interaction.DragRotateAndZoom}
* @private
*/
ol.interaction.DragRotateAndZoom.handleDragEvent_ = function(mapBrowserEvent) {
if (!ol.events.condition.mouseOnly(mapBrowserEvent)) {
_ol_interaction_DragRotateAndZoom_.handleDragEvent_ = function(mapBrowserEvent) {
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) {
return;
}
@@ -86,15 +87,15 @@ ol.interaction.DragRotateAndZoom.handleDragEvent_ = function(mapBrowserEvent) {
var theta = Math.atan2(deltaY, deltaX);
var magnitude = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
var view = map.getView();
if (view.getConstraints().rotation !== ol.RotationConstraint.disable && this.lastAngle_ !== undefined) {
if (view.getConstraints().rotation !== _ol_RotationConstraint_.disable && this.lastAngle_ !== undefined) {
var angleDelta = theta - this.lastAngle_;
ol.interaction.Interaction.rotateWithoutConstraints(
_ol_interaction_Interaction_.rotateWithoutConstraints(
view, view.getRotation() - angleDelta);
}
this.lastAngle_ = theta;
if (this.lastMagnitude_ !== undefined) {
var resolution = this.lastMagnitude_ * (view.getResolution() / magnitude);
ol.interaction.Interaction.zoomWithoutConstraints(view, resolution);
_ol_interaction_Interaction_.zoomWithoutConstraints(view, resolution);
}
if (this.lastMagnitude_ !== undefined) {
this.lastScaleDelta_ = this.lastMagnitude_ / magnitude;
@@ -109,17 +110,17 @@ ol.interaction.DragRotateAndZoom.handleDragEvent_ = function(mapBrowserEvent) {
* @this {ol.interaction.DragRotateAndZoom}
* @private
*/
ol.interaction.DragRotateAndZoom.handleUpEvent_ = function(mapBrowserEvent) {
if (!ol.events.condition.mouseOnly(mapBrowserEvent)) {
_ol_interaction_DragRotateAndZoom_.handleUpEvent_ = function(mapBrowserEvent) {
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) {
return true;
}
var map = mapBrowserEvent.map;
var view = map.getView();
view.setHint(ol.ViewHint.INTERACTING, -1);
view.setHint(_ol_ViewHint_.INTERACTING, -1);
var direction = this.lastScaleDelta_ - 1;
ol.interaction.Interaction.rotate(view, view.getRotation());
ol.interaction.Interaction.zoom(view, view.getResolution(),
_ol_interaction_Interaction_.rotate(view, view.getRotation());
_ol_interaction_Interaction_.zoom(view, view.getResolution(),
undefined, this.duration_, direction);
this.lastScaleDelta_ = 0;
return false;
@@ -132,13 +133,13 @@ ol.interaction.DragRotateAndZoom.handleUpEvent_ = function(mapBrowserEvent) {
* @this {ol.interaction.DragRotateAndZoom}
* @private
*/
ol.interaction.DragRotateAndZoom.handleDownEvent_ = function(mapBrowserEvent) {
if (!ol.events.condition.mouseOnly(mapBrowserEvent)) {
_ol_interaction_DragRotateAndZoom_.handleDownEvent_ = function(mapBrowserEvent) {
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) {
return false;
}
if (this.condition_(mapBrowserEvent)) {
mapBrowserEvent.map.getView().setHint(ol.ViewHint.INTERACTING, 1);
mapBrowserEvent.map.getView().setHint(_ol_ViewHint_.INTERACTING, 1);
this.lastAngle_ = undefined;
this.lastMagnitude_ = undefined;
return true;
@@ -146,3 +147,4 @@ ol.interaction.DragRotateAndZoom.handleDownEvent_ = function(mapBrowserEvent) {
return false;
}
};
export default _ol_interaction_DragRotateAndZoom_;

View File

@@ -1,11 +1,11 @@
goog.provide('ol.interaction.DragZoom');
goog.require('ol');
goog.require('ol.easing');
goog.require('ol.events.condition');
goog.require('ol.extent');
goog.require('ol.interaction.DragBox');
/**
* @module ol/interaction/DragZoom
*/
import _ol_ from '../index.js';
import _ol_easing_ from '../easing.js';
import _ol_events_condition_ from '../events/condition.js';
import _ol_extent_ from '../extent.js';
import _ol_interaction_DragBox_ from '../interaction/DragBox.js';
/**
* @classdesc
@@ -21,11 +21,11 @@ goog.require('ol.interaction.DragBox');
* @param {olx.interaction.DragZoomOptions=} opt_options Options.
* @api
*/
ol.interaction.DragZoom = function(opt_options) {
var _ol_interaction_DragZoom_ = function(opt_options) {
var options = opt_options ? opt_options : {};
var condition = options.condition ?
options.condition : ol.events.condition.shiftKeyOnly;
options.condition : _ol_events_condition_.shiftKeyOnly;
/**
* @private
@@ -39,19 +39,20 @@ ol.interaction.DragZoom = function(opt_options) {
*/
this.out_ = options.out !== undefined ? options.out : false;
ol.interaction.DragBox.call(this, {
_ol_interaction_DragBox_.call(this, {
condition: condition,
className: options.className || 'ol-dragzoom'
});
};
ol.inherits(ol.interaction.DragZoom, ol.interaction.DragBox);
_ol_.inherits(_ol_interaction_DragZoom_, _ol_interaction_DragBox_);
/**
* @inheritDoc
*/
ol.interaction.DragZoom.prototype.onBoxEnd = function() {
_ol_interaction_DragZoom_.prototype.onBoxEnd = function() {
var map = this.getMap();
var view = /** @type {!ol.View} */ (map.getView());
@@ -62,26 +63,27 @@ ol.interaction.DragZoom.prototype.onBoxEnd = function() {
if (this.out_) {
var mapExtent = view.calculateExtent(size);
var boxPixelExtent = ol.extent.createOrUpdateFromCoordinates([
map.getPixelFromCoordinate(ol.extent.getBottomLeft(extent)),
map.getPixelFromCoordinate(ol.extent.getTopRight(extent))]);
var boxPixelExtent = _ol_extent_.createOrUpdateFromCoordinates([
map.getPixelFromCoordinate(_ol_extent_.getBottomLeft(extent)),
map.getPixelFromCoordinate(_ol_extent_.getTopRight(extent))]);
var factor = view.getResolutionForExtent(boxPixelExtent, size);
ol.extent.scaleFromCenter(mapExtent, 1 / factor);
_ol_extent_.scaleFromCenter(mapExtent, 1 / factor);
extent = mapExtent;
}
var resolution = view.constrainResolution(
view.getResolutionForExtent(extent, size));
var center = ol.extent.getCenter(extent);
var center = _ol_extent_.getCenter(extent);
center = view.constrainCenter(center);
view.animate({
resolution: resolution,
center: center,
duration: this.duration_,
easing: ol.easing.easeOut
easing: _ol_easing_.easeOut
});
};
export default _ol_interaction_DragZoom_;

View File

@@ -1,30 +1,30 @@
goog.provide('ol.interaction.Draw');
goog.require('ol');
goog.require('ol.Feature');
goog.require('ol.MapBrowserEventType');
goog.require('ol.Object');
goog.require('ol.coordinate');
goog.require('ol.events');
goog.require('ol.events.Event');
goog.require('ol.events.condition');
goog.require('ol.extent');
goog.require('ol.functions');
goog.require('ol.geom.Circle');
goog.require('ol.geom.GeometryType');
goog.require('ol.geom.LineString');
goog.require('ol.geom.MultiLineString');
goog.require('ol.geom.MultiPoint');
goog.require('ol.geom.MultiPolygon');
goog.require('ol.geom.Point');
goog.require('ol.geom.Polygon');
goog.require('ol.interaction.DrawEventType');
goog.require('ol.interaction.Pointer');
goog.require('ol.interaction.Property');
goog.require('ol.layer.Vector');
goog.require('ol.source.Vector');
goog.require('ol.style.Style');
/**
* @module ol/interaction/Draw
*/
import _ol_ from '../index.js';
import _ol_Feature_ from '../Feature.js';
import _ol_MapBrowserEventType_ from '../MapBrowserEventType.js';
import _ol_Object_ from '../Object.js';
import _ol_coordinate_ from '../coordinate.js';
import _ol_events_ from '../events.js';
import _ol_events_Event_ from '../events/Event.js';
import _ol_events_condition_ from '../events/condition.js';
import _ol_extent_ from '../extent.js';
import _ol_functions_ from '../functions.js';
import _ol_geom_Circle_ from '../geom/Circle.js';
import _ol_geom_GeometryType_ from '../geom/GeometryType.js';
import _ol_geom_LineString_ from '../geom/LineString.js';
import _ol_geom_MultiLineString_ from '../geom/MultiLineString.js';
import _ol_geom_MultiPoint_ from '../geom/MultiPoint.js';
import _ol_geom_MultiPolygon_ from '../geom/MultiPolygon.js';
import _ol_geom_Point_ from '../geom/Point.js';
import _ol_geom_Polygon_ from '../geom/Polygon.js';
import _ol_interaction_DrawEventType_ from '../interaction/DrawEventType.js';
import _ol_interaction_Pointer_ from '../interaction/Pointer.js';
import _ol_interaction_Property_ from '../interaction/Property.js';
import _ol_layer_Vector_ from '../layer/Vector.js';
import _ol_source_Vector_ from '../source/Vector.js';
import _ol_style_Style_ from '../style/Style.js';
/**
* @classdesc
@@ -36,12 +36,12 @@ goog.require('ol.style.Style');
* @param {olx.interaction.DrawOptions} options Options.
* @api
*/
ol.interaction.Draw = function(options) {
var _ol_interaction_Draw_ = function(options) {
ol.interaction.Pointer.call(this, {
handleDownEvent: ol.interaction.Draw.handleDownEvent_,
handleEvent: ol.interaction.Draw.handleEvent,
handleUpEvent: ol.interaction.Draw.handleUpEvent_
_ol_interaction_Pointer_.call(this, {
handleDownEvent: _ol_interaction_Draw_.handleDownEvent_,
handleEvent: _ol_interaction_Draw_.handleEvent,
handleUpEvent: _ol_interaction_Draw_.handleUpEvent_
});
/**
@@ -95,7 +95,7 @@ ol.interaction.Draw = function(options) {
* @type {ol.interaction.Draw.Mode_}
* @private
*/
this.mode_ = ol.interaction.Draw.getMode_(this.type_);
this.mode_ = _ol_interaction_Draw_.getMode_(this.type_);
/**
* Stop click, singleclick, and doubleclick events from firing during drawing.
@@ -114,7 +114,7 @@ ol.interaction.Draw = function(options) {
*/
this.minPoints_ = options.minPoints ?
options.minPoints :
(this.mode_ === ol.interaction.Draw.Mode_.POLYGON ? 3 : 2);
(this.mode_ === _ol_interaction_Draw_.Mode_.POLYGON ? 3 : 2);
/**
* The number of points that can be drawn before a polygon ring or line string
@@ -129,11 +129,11 @@ ol.interaction.Draw = function(options) {
* @private
* @type {ol.EventsConditionType}
*/
this.finishCondition_ = options.finishCondition ? options.finishCondition : ol.functions.TRUE;
this.finishCondition_ = options.finishCondition ? options.finishCondition : _ol_functions_.TRUE;
var geometryFunction = options.geometryFunction;
if (!geometryFunction) {
if (this.type_ === ol.geom.GeometryType.CIRCLE) {
if (this.type_ === _ol_geom_GeometryType_.CIRCLE) {
/**
* @param {!Array.<ol.Coordinate>} coordinates
* The coordinates.
@@ -142,8 +142,8 @@ ol.interaction.Draw = function(options) {
*/
geometryFunction = function(coordinates, opt_geometry) {
var circle = opt_geometry ? /** @type {ol.geom.Circle} */ (opt_geometry) :
new ol.geom.Circle([NaN, NaN]);
var squaredLength = ol.coordinate.squaredDistance(
new _ol_geom_Circle_([NaN, NaN]);
var squaredLength = _ol_coordinate_.squaredDistance(
coordinates[0], coordinates[1]);
circle.setCenterAndRadius(coordinates[0], Math.sqrt(squaredLength));
return circle;
@@ -151,12 +151,12 @@ ol.interaction.Draw = function(options) {
} else {
var Constructor;
var mode = this.mode_;
if (mode === ol.interaction.Draw.Mode_.POINT) {
Constructor = ol.geom.Point;
} else if (mode === ol.interaction.Draw.Mode_.LINE_STRING) {
Constructor = ol.geom.LineString;
} else if (mode === ol.interaction.Draw.Mode_.POLYGON) {
Constructor = ol.geom.Polygon;
if (mode === _ol_interaction_Draw_.Mode_.POINT) {
Constructor = _ol_geom_Point_;
} else if (mode === _ol_interaction_Draw_.Mode_.LINE_STRING) {
Constructor = _ol_geom_LineString_;
} else if (mode === _ol_interaction_Draw_.Mode_.POLYGON) {
Constructor = _ol_geom_Polygon_;
}
/**
* @param {!Array.<ol.Coordinate>} coordinates
@@ -167,7 +167,7 @@ ol.interaction.Draw = function(options) {
geometryFunction = function(coordinates, opt_geometry) {
var geometry = opt_geometry;
if (geometry) {
if (mode === ol.interaction.Draw.Mode_.POLYGON) {
if (mode === _ol_interaction_Draw_.Mode_.POLYGON) {
if (coordinates[0].length) {
// Add a closing coordinate to match the first
geometry.setCoordinates([coordinates[0].concat([coordinates[0][0]])]);
@@ -249,13 +249,13 @@ ol.interaction.Draw = function(options) {
* @type {ol.layer.Vector}
* @private
*/
this.overlay_ = new ol.layer.Vector({
source: new ol.source.Vector({
this.overlay_ = new _ol_layer_Vector_({
source: new _ol_source_Vector_({
useSpatialIndex: false,
wrapX: options.wrapX ? options.wrapX : false
}),
style: options.style ? options.style :
ol.interaction.Draw.getDefaultStyleFunction()
_ol_interaction_Draw_.getDefaultStyleFunction()
});
/**
@@ -270,7 +270,7 @@ ol.interaction.Draw = function(options) {
* @type {ol.EventsConditionType}
*/
this.condition_ = options.condition ?
options.condition : ol.events.condition.noModifierKeys;
options.condition : _ol_events_condition_.noModifierKeys;
/**
* @private
@@ -278,25 +278,26 @@ ol.interaction.Draw = function(options) {
*/
this.freehandCondition_;
if (options.freehand) {
this.freehandCondition_ = ol.events.condition.always;
this.freehandCondition_ = _ol_events_condition_.always;
} else {
this.freehandCondition_ = options.freehandCondition ?
options.freehandCondition : ol.events.condition.shiftKeyOnly;
options.freehandCondition : _ol_events_condition_.shiftKeyOnly;
}
ol.events.listen(this,
ol.Object.getChangeEventType(ol.interaction.Property.ACTIVE),
_ol_events_.listen(this,
_ol_Object_.getChangeEventType(_ol_interaction_Property_.ACTIVE),
this.updateState_, this);
};
ol.inherits(ol.interaction.Draw, ol.interaction.Pointer);
_ol_.inherits(_ol_interaction_Draw_, _ol_interaction_Pointer_);
/**
* @return {ol.StyleFunction} Styles.
*/
ol.interaction.Draw.getDefaultStyleFunction = function() {
var styles = ol.style.Style.createDefaultEditing();
_ol_interaction_Draw_.getDefaultStyleFunction = function() {
var styles = _ol_style_Style_.createDefaultEditing();
return function(feature, resolution) {
return styles[feature.getGeometry().getType()];
};
@@ -306,8 +307,8 @@ ol.interaction.Draw.getDefaultStyleFunction = function() {
/**
* @inheritDoc
*/
ol.interaction.Draw.prototype.setMap = function(map) {
ol.interaction.Pointer.prototype.setMap.call(this, map);
_ol_interaction_Draw_.prototype.setMap = function(map) {
_ol_interaction_Pointer_.prototype.setMap.call(this, map);
this.updateState_();
};
@@ -320,23 +321,23 @@ ol.interaction.Draw.prototype.setMap = function(map) {
* @this {ol.interaction.Draw}
* @api
*/
ol.interaction.Draw.handleEvent = function(event) {
this.freehand_ = this.mode_ !== ol.interaction.Draw.Mode_.POINT && this.freehandCondition_(event);
_ol_interaction_Draw_.handleEvent = function(event) {
this.freehand_ = this.mode_ !== _ol_interaction_Draw_.Mode_.POINT && this.freehandCondition_(event);
var pass = true;
if (this.freehand_ &&
event.type === ol.MapBrowserEventType.POINTERDRAG &&
event.type === _ol_MapBrowserEventType_.POINTERDRAG &&
this.sketchFeature_ !== null) {
this.addToDrawing_(event);
pass = false;
} else if (this.freehand_ &&
event.type === ol.MapBrowserEventType.POINTERDOWN) {
event.type === _ol_MapBrowserEventType_.POINTERDOWN) {
pass = false;
} else if (event.type === ol.MapBrowserEventType.POINTERMOVE) {
} else if (event.type === _ol_MapBrowserEventType_.POINTERMOVE) {
pass = this.handlePointerMove_(event);
} else if (event.type === ol.MapBrowserEventType.DBLCLICK) {
} else if (event.type === _ol_MapBrowserEventType_.DBLCLICK) {
pass = false;
}
return ol.interaction.Pointer.handleEvent.call(this, event) && pass;
return _ol_interaction_Pointer_.handleEvent.call(this, event) && pass;
};
@@ -346,7 +347,7 @@ ol.interaction.Draw.handleEvent = function(event) {
* @this {ol.interaction.Draw}
* @private
*/
ol.interaction.Draw.handleDownEvent_ = function(event) {
_ol_interaction_Draw_.handleDownEvent_ = function(event) {
this.shouldHandle_ = !this.freehand_;
if (this.freehand_) {
@@ -370,17 +371,17 @@ ol.interaction.Draw.handleDownEvent_ = function(event) {
* @this {ol.interaction.Draw}
* @private
*/
ol.interaction.Draw.handleUpEvent_ = function(event) {
_ol_interaction_Draw_.handleUpEvent_ = function(event) {
var pass = true;
this.handlePointerMove_(event);
var circleMode = this.mode_ === ol.interaction.Draw.Mode_.CIRCLE;
var circleMode = this.mode_ === _ol_interaction_Draw_.Mode_.CIRCLE;
if (this.shouldHandle_) {
if (!this.finishCoordinate_) {
this.startDrawing_(event);
if (this.mode_ === ol.interaction.Draw.Mode_.POINT) {
if (this.mode_ === _ol_interaction_Draw_.Mode_.POINT) {
this.finishDrawing();
}
} else if (this.freehand_ || circleMode) {
@@ -410,7 +411,7 @@ ol.interaction.Draw.handleUpEvent_ = function(event) {
* @return {boolean} Pass the event to other interactions.
* @private
*/
ol.interaction.Draw.prototype.handlePointerMove_ = function(event) {
_ol_interaction_Draw_.prototype.handlePointerMove_ = function(event) {
if (this.downPx_ &&
((!this.freehand_ && this.shouldHandle_) ||
(this.freehand_ && !this.shouldHandle_))) {
@@ -439,14 +440,14 @@ ol.interaction.Draw.prototype.handlePointerMove_ = function(event) {
* @return {boolean} The event is within the snapping tolerance of the start.
* @private
*/
ol.interaction.Draw.prototype.atFinish_ = function(event) {
_ol_interaction_Draw_.prototype.atFinish_ = function(event) {
var at = false;
if (this.sketchFeature_) {
var potentiallyDone = false;
var potentiallyFinishCoordinates = [this.finishCoordinate_];
if (this.mode_ === ol.interaction.Draw.Mode_.LINE_STRING) {
if (this.mode_ === _ol_interaction_Draw_.Mode_.LINE_STRING) {
potentiallyDone = this.sketchCoords_.length > this.minPoints_;
} else if (this.mode_ === ol.interaction.Draw.Mode_.POLYGON) {
} else if (this.mode_ === _ol_interaction_Draw_.Mode_.POLYGON) {
potentiallyDone = this.sketchCoords_[0].length >
this.minPoints_;
potentiallyFinishCoordinates = [this.sketchCoords_[0][0],
@@ -477,10 +478,10 @@ ol.interaction.Draw.prototype.atFinish_ = function(event) {
* @param {ol.MapBrowserEvent} event Event.
* @private
*/
ol.interaction.Draw.prototype.createOrUpdateSketchPoint_ = function(event) {
_ol_interaction_Draw_.prototype.createOrUpdateSketchPoint_ = function(event) {
var coordinates = event.coordinate.slice();
if (!this.sketchPoint_) {
this.sketchPoint_ = new ol.Feature(new ol.geom.Point(coordinates));
this.sketchPoint_ = new _ol_Feature_(new _ol_geom_Point_(coordinates));
this.updateSketchFeatures_();
} else {
var sketchPointGeom = /** @type {ol.geom.Point} */ (this.sketchPoint_.getGeometry());
@@ -494,33 +495,33 @@ ol.interaction.Draw.prototype.createOrUpdateSketchPoint_ = function(event) {
* @param {ol.MapBrowserEvent} event Event.
* @private
*/
ol.interaction.Draw.prototype.startDrawing_ = function(event) {
_ol_interaction_Draw_.prototype.startDrawing_ = function(event) {
var start = event.coordinate;
this.finishCoordinate_ = start;
if (this.mode_ === ol.interaction.Draw.Mode_.POINT) {
if (this.mode_ === _ol_interaction_Draw_.Mode_.POINT) {
this.sketchCoords_ = start.slice();
} else if (this.mode_ === ol.interaction.Draw.Mode_.POLYGON) {
} else if (this.mode_ === _ol_interaction_Draw_.Mode_.POLYGON) {
this.sketchCoords_ = [[start.slice(), start.slice()]];
this.sketchLineCoords_ = this.sketchCoords_[0];
} else {
this.sketchCoords_ = [start.slice(), start.slice()];
if (this.mode_ === ol.interaction.Draw.Mode_.CIRCLE) {
if (this.mode_ === _ol_interaction_Draw_.Mode_.CIRCLE) {
this.sketchLineCoords_ = this.sketchCoords_;
}
}
if (this.sketchLineCoords_) {
this.sketchLine_ = new ol.Feature(
new ol.geom.LineString(this.sketchLineCoords_));
this.sketchLine_ = new _ol_Feature_(
new _ol_geom_LineString_(this.sketchLineCoords_));
}
var geometry = this.geometryFunction_(this.sketchCoords_);
this.sketchFeature_ = new ol.Feature();
this.sketchFeature_ = new _ol_Feature_();
if (this.geometryName_) {
this.sketchFeature_.setGeometryName(this.geometryName_);
}
this.sketchFeature_.setGeometry(geometry);
this.updateSketchFeatures_();
this.dispatchEvent(new ol.interaction.Draw.Event(
ol.interaction.DrawEventType.DRAWSTART, this.sketchFeature_));
this.dispatchEvent(new _ol_interaction_Draw_.Event(
_ol_interaction_DrawEventType_.DRAWSTART, this.sketchFeature_));
};
@@ -529,13 +530,13 @@ ol.interaction.Draw.prototype.startDrawing_ = function(event) {
* @param {ol.MapBrowserEvent} event Event.
* @private
*/
ol.interaction.Draw.prototype.modifyDrawing_ = function(event) {
_ol_interaction_Draw_.prototype.modifyDrawing_ = function(event) {
var coordinate = event.coordinate;
var geometry = /** @type {ol.geom.SimpleGeometry} */ (this.sketchFeature_.getGeometry());
var coordinates, last;
if (this.mode_ === ol.interaction.Draw.Mode_.POINT) {
if (this.mode_ === _ol_interaction_Draw_.Mode_.POINT) {
last = this.sketchCoords_;
} else if (this.mode_ === ol.interaction.Draw.Mode_.POLYGON) {
} else if (this.mode_ === _ol_interaction_Draw_.Mode_.POLYGON) {
coordinates = this.sketchCoords_[0];
last = coordinates[coordinates.length - 1];
if (this.atFinish_(event)) {
@@ -554,10 +555,10 @@ ol.interaction.Draw.prototype.modifyDrawing_ = function(event) {
sketchPointGeom.setCoordinates(coordinate);
}
var sketchLineGeom;
if (geometry instanceof ol.geom.Polygon &&
this.mode_ !== ol.interaction.Draw.Mode_.POLYGON) {
if (geometry instanceof _ol_geom_Polygon_ &&
this.mode_ !== _ol_interaction_Draw_.Mode_.POLYGON) {
if (!this.sketchLine_) {
this.sketchLine_ = new ol.Feature(new ol.geom.LineString(null));
this.sketchLine_ = new _ol_Feature_(new _ol_geom_LineString_(null));
}
var ring = geometry.getLinearRing(0);
sketchLineGeom = /** @type {ol.geom.LineString} */ (this.sketchLine_.getGeometry());
@@ -576,12 +577,12 @@ ol.interaction.Draw.prototype.modifyDrawing_ = function(event) {
* @param {ol.MapBrowserEvent} event Event.
* @private
*/
ol.interaction.Draw.prototype.addToDrawing_ = function(event) {
_ol_interaction_Draw_.prototype.addToDrawing_ = function(event) {
var coordinate = event.coordinate;
var geometry = /** @type {ol.geom.SimpleGeometry} */ (this.sketchFeature_.getGeometry());
var done;
var coordinates;
if (this.mode_ === ol.interaction.Draw.Mode_.LINE_STRING) {
if (this.mode_ === _ol_interaction_Draw_.Mode_.LINE_STRING) {
this.finishCoordinate_ = coordinate.slice();
coordinates = this.sketchCoords_;
if (coordinates.length >= this.maxPoints_) {
@@ -593,7 +594,7 @@ ol.interaction.Draw.prototype.addToDrawing_ = function(event) {
}
coordinates.push(coordinate.slice());
this.geometryFunction_(coordinates, geometry);
} else if (this.mode_ === ol.interaction.Draw.Mode_.POLYGON) {
} else if (this.mode_ === _ol_interaction_Draw_.Mode_.POLYGON) {
coordinates = this.sketchCoords_[0];
if (coordinates.length >= this.maxPoints_) {
if (this.freehand_) {
@@ -619,20 +620,20 @@ ol.interaction.Draw.prototype.addToDrawing_ = function(event) {
* Remove last point of the feature currently being drawn.
* @api
*/
ol.interaction.Draw.prototype.removeLastPoint = function() {
_ol_interaction_Draw_.prototype.removeLastPoint = function() {
if (!this.sketchFeature_) {
return;
}
var geometry = /** @type {ol.geom.SimpleGeometry} */ (this.sketchFeature_.getGeometry());
var coordinates, sketchLineGeom;
if (this.mode_ === ol.interaction.Draw.Mode_.LINE_STRING) {
if (this.mode_ === _ol_interaction_Draw_.Mode_.LINE_STRING) {
coordinates = this.sketchCoords_;
coordinates.splice(-2, 1);
this.geometryFunction_(coordinates, geometry);
if (coordinates.length >= 2) {
this.finishCoordinate_ = coordinates[coordinates.length - 2].slice();
}
} else if (this.mode_ === ol.interaction.Draw.Mode_.POLYGON) {
} else if (this.mode_ === _ol_interaction_Draw_.Mode_.POLYGON) {
coordinates = this.sketchCoords_[0];
coordinates.splice(-2, 1);
sketchLineGeom = /** @type {ol.geom.LineString} */ (this.sketchLine_.getGeometry());
@@ -654,15 +655,15 @@ ol.interaction.Draw.prototype.removeLastPoint = function() {
* inserting the feature.
* @api
*/
ol.interaction.Draw.prototype.finishDrawing = function() {
_ol_interaction_Draw_.prototype.finishDrawing = function() {
var sketchFeature = this.abortDrawing_();
var coordinates = this.sketchCoords_;
var geometry = /** @type {ol.geom.SimpleGeometry} */ (sketchFeature.getGeometry());
if (this.mode_ === ol.interaction.Draw.Mode_.LINE_STRING) {
if (this.mode_ === _ol_interaction_Draw_.Mode_.LINE_STRING) {
// remove the redundant last point
coordinates.pop();
this.geometryFunction_(coordinates, geometry);
} else if (this.mode_ === ol.interaction.Draw.Mode_.POLYGON) {
} else if (this.mode_ === _ol_interaction_Draw_.Mode_.POLYGON) {
// remove the redundant last point in ring
coordinates[0].pop();
this.geometryFunction_(coordinates, geometry);
@@ -670,17 +671,17 @@ ol.interaction.Draw.prototype.finishDrawing = function() {
}
// cast multi-part geometries
if (this.type_ === ol.geom.GeometryType.MULTI_POINT) {
sketchFeature.setGeometry(new ol.geom.MultiPoint([coordinates]));
} else if (this.type_ === ol.geom.GeometryType.MULTI_LINE_STRING) {
sketchFeature.setGeometry(new ol.geom.MultiLineString([coordinates]));
} else if (this.type_ === ol.geom.GeometryType.MULTI_POLYGON) {
sketchFeature.setGeometry(new ol.geom.MultiPolygon([coordinates]));
if (this.type_ === _ol_geom_GeometryType_.MULTI_POINT) {
sketchFeature.setGeometry(new _ol_geom_MultiPoint_([coordinates]));
} else if (this.type_ === _ol_geom_GeometryType_.MULTI_LINE_STRING) {
sketchFeature.setGeometry(new _ol_geom_MultiLineString_([coordinates]));
} else if (this.type_ === _ol_geom_GeometryType_.MULTI_POLYGON) {
sketchFeature.setGeometry(new _ol_geom_MultiPolygon_([coordinates]));
}
// First dispatch event to allow full set up of feature
this.dispatchEvent(new ol.interaction.Draw.Event(
ol.interaction.DrawEventType.DRAWEND, sketchFeature));
this.dispatchEvent(new _ol_interaction_Draw_.Event(
_ol_interaction_DrawEventType_.DRAWEND, sketchFeature));
// Then insert feature
if (this.features_) {
@@ -697,7 +698,7 @@ ol.interaction.Draw.prototype.finishDrawing = function() {
* @return {ol.Feature} The sketch feature (or null if none).
* @private
*/
ol.interaction.Draw.prototype.abortDrawing_ = function() {
_ol_interaction_Draw_.prototype.abortDrawing_ = function() {
this.finishCoordinate_ = null;
var sketchFeature = this.sketchFeature_;
if (sketchFeature) {
@@ -717,7 +718,7 @@ ol.interaction.Draw.prototype.abortDrawing_ = function() {
* @param {!ol.Feature} feature Feature to be extended.
* @api
*/
ol.interaction.Draw.prototype.extend = function(feature) {
_ol_interaction_Draw_.prototype.extend = function(feature) {
var geometry = feature.getGeometry();
var lineString = /** @type {ol.geom.LineString} */ (geometry);
this.sketchFeature_ = feature;
@@ -726,22 +727,22 @@ ol.interaction.Draw.prototype.extend = function(feature) {
this.finishCoordinate_ = last.slice();
this.sketchCoords_.push(last.slice());
this.updateSketchFeatures_();
this.dispatchEvent(new ol.interaction.Draw.Event(
ol.interaction.DrawEventType.DRAWSTART, this.sketchFeature_));
this.dispatchEvent(new _ol_interaction_Draw_.Event(
_ol_interaction_DrawEventType_.DRAWSTART, this.sketchFeature_));
};
/**
* @inheritDoc
*/
ol.interaction.Draw.prototype.shouldStopEvent = ol.functions.FALSE;
_ol_interaction_Draw_.prototype.shouldStopEvent = _ol_functions_.FALSE;
/**
* Redraw the sketch features.
* @private
*/
ol.interaction.Draw.prototype.updateSketchFeatures_ = function() {
_ol_interaction_Draw_.prototype.updateSketchFeatures_ = function() {
var sketchFeatures = [];
if (this.sketchFeature_) {
sketchFeatures.push(this.sketchFeature_);
@@ -761,7 +762,7 @@ ol.interaction.Draw.prototype.updateSketchFeatures_ = function() {
/**
* @private
*/
ol.interaction.Draw.prototype.updateState_ = function() {
_ol_interaction_Draw_.prototype.updateState_ = function() {
var map = this.getMap();
var active = this.getActive();
if (!map || !active) {
@@ -784,23 +785,23 @@ ol.interaction.Draw.prototype.updateState_ = function() {
* polygon.
* @api
*/
ol.interaction.Draw.createRegularPolygon = function(opt_sides, opt_angle) {
_ol_interaction_Draw_.createRegularPolygon = function(opt_sides, opt_angle) {
return (
/**
* @param {ol.Coordinate|Array.<ol.Coordinate>|Array.<Array.<ol.Coordinate>>} coordinates
* @param {ol.geom.SimpleGeometry=} opt_geometry
* @return {ol.geom.SimpleGeometry}
*/
/**
* @param {ol.Coordinate|Array.<ol.Coordinate>|Array.<Array.<ol.Coordinate>>} coordinates
* @param {ol.geom.SimpleGeometry=} opt_geometry
* @return {ol.geom.SimpleGeometry}
*/
function(coordinates, opt_geometry) {
var center = coordinates[0];
var end = coordinates[1];
var radius = Math.sqrt(
ol.coordinate.squaredDistance(center, end));
_ol_coordinate_.squaredDistance(center, end));
var geometry = opt_geometry ? /** @type {ol.geom.Polygon} */ (opt_geometry) :
ol.geom.Polygon.fromCircle(new ol.geom.Circle(center), opt_sides);
_ol_geom_Polygon_.fromCircle(new _ol_geom_Circle_(center), opt_sides);
var angle = opt_angle ? opt_angle :
Math.atan((end[1] - center[1]) / (end[0] - center[0]));
ol.geom.Polygon.makeRegular(geometry, center, radius, angle);
_ol_geom_Polygon_.makeRegular(geometry, center, radius, angle);
return geometry;
}
);
@@ -814,7 +815,7 @@ ol.interaction.Draw.createRegularPolygon = function(opt_sides, opt_angle) {
* @return {ol.DrawGeometryFunctionType} Function that draws a box-shaped polygon.
* @api
*/
ol.interaction.Draw.createBox = function() {
_ol_interaction_Draw_.createBox = function() {
return (
/**
* @param {Array.<ol.Coordinate>} coordinates
@@ -822,14 +823,14 @@ ol.interaction.Draw.createBox = function() {
* @return {ol.geom.SimpleGeometry}
*/
function(coordinates, opt_geometry) {
var extent = ol.extent.boundingExtent(coordinates);
var geometry = opt_geometry || new ol.geom.Polygon(null);
var extent = _ol_extent_.boundingExtent(coordinates);
var geometry = opt_geometry || new _ol_geom_Polygon_(null);
geometry.setCoordinates([[
ol.extent.getBottomLeft(extent),
ol.extent.getBottomRight(extent),
ol.extent.getTopRight(extent),
ol.extent.getTopLeft(extent),
ol.extent.getBottomLeft(extent)
_ol_extent_.getBottomLeft(extent),
_ol_extent_.getBottomRight(extent),
_ol_extent_.getTopRight(extent),
_ol_extent_.getTopLeft(extent),
_ol_extent_.getBottomLeft(extent)
]]);
return geometry;
}
@@ -844,19 +845,19 @@ ol.interaction.Draw.createBox = function() {
* @return {ol.interaction.Draw.Mode_} Drawing mode.
* @private
*/
ol.interaction.Draw.getMode_ = function(type) {
_ol_interaction_Draw_.getMode_ = function(type) {
var mode;
if (type === ol.geom.GeometryType.POINT ||
type === ol.geom.GeometryType.MULTI_POINT) {
mode = ol.interaction.Draw.Mode_.POINT;
} else if (type === ol.geom.GeometryType.LINE_STRING ||
type === ol.geom.GeometryType.MULTI_LINE_STRING) {
mode = ol.interaction.Draw.Mode_.LINE_STRING;
} else if (type === ol.geom.GeometryType.POLYGON ||
type === ol.geom.GeometryType.MULTI_POLYGON) {
mode = ol.interaction.Draw.Mode_.POLYGON;
} else if (type === ol.geom.GeometryType.CIRCLE) {
mode = ol.interaction.Draw.Mode_.CIRCLE;
if (type === _ol_geom_GeometryType_.POINT ||
type === _ol_geom_GeometryType_.MULTI_POINT) {
mode = _ol_interaction_Draw_.Mode_.POINT;
} else if (type === _ol_geom_GeometryType_.LINE_STRING ||
type === _ol_geom_GeometryType_.MULTI_LINE_STRING) {
mode = _ol_interaction_Draw_.Mode_.LINE_STRING;
} else if (type === _ol_geom_GeometryType_.POLYGON ||
type === _ol_geom_GeometryType_.MULTI_POLYGON) {
mode = _ol_interaction_Draw_.Mode_.POLYGON;
} else if (type === _ol_geom_GeometryType_.CIRCLE) {
mode = _ol_interaction_Draw_.Mode_.CIRCLE;
}
return /** @type {!ol.interaction.Draw.Mode_} */ (mode);
};
@@ -868,7 +869,7 @@ ol.interaction.Draw.getMode_ = function(type) {
* @enum {string}
* @private
*/
ol.interaction.Draw.Mode_ = {
_ol_interaction_Draw_.Mode_ = {
POINT: 'Point',
LINE_STRING: 'LineString',
POLYGON: 'Polygon',
@@ -886,9 +887,9 @@ ol.interaction.Draw.Mode_ = {
* @param {ol.interaction.DrawEventType} type Type.
* @param {ol.Feature} feature The feature drawn.
*/
ol.interaction.Draw.Event = function(type, feature) {
_ol_interaction_Draw_.Event = function(type, feature) {
ol.events.Event.call(this, type);
_ol_events_Event_.call(this, type);
/**
* The feature being drawn.
@@ -898,4 +899,5 @@ ol.interaction.Draw.Event = function(type, feature) {
this.feature = feature;
};
ol.inherits(ol.interaction.Draw.Event, ol.events.Event);
_ol_.inherits(_ol_interaction_Draw_.Event, _ol_events_Event_);
export default _ol_interaction_Draw_;

View File

@@ -1,10 +1,10 @@
goog.provide('ol.interaction.DrawEventType');
/**
* @module ol/interaction/DrawEventType
*/
/**
* @enum {string}
*/
ol.interaction.DrawEventType = {
var _ol_interaction_DrawEventType_ = {
/**
* Triggered upon feature draw start
* @event ol.interaction.Draw.Event#drawstart
@@ -18,3 +18,5 @@ ol.interaction.DrawEventType = {
*/
DRAWEND: 'drawend'
};
export default _ol_interaction_DrawEventType_;

View File

@@ -1,21 +1,21 @@
goog.provide('ol.interaction.Extent');
goog.require('ol');
goog.require('ol.Feature');
goog.require('ol.MapBrowserEventType');
goog.require('ol.MapBrowserPointerEvent');
goog.require('ol.coordinate');
goog.require('ol.events.Event');
goog.require('ol.extent');
goog.require('ol.geom.GeometryType');
goog.require('ol.geom.Point');
goog.require('ol.geom.Polygon');
goog.require('ol.interaction.ExtentEventType');
goog.require('ol.interaction.Pointer');
goog.require('ol.layer.Vector');
goog.require('ol.source.Vector');
goog.require('ol.style.Style');
/**
* @module ol/interaction/Extent
*/
import _ol_ from '../index.js';
import _ol_Feature_ from '../Feature.js';
import _ol_MapBrowserEventType_ from '../MapBrowserEventType.js';
import _ol_MapBrowserPointerEvent_ from '../MapBrowserPointerEvent.js';
import _ol_coordinate_ from '../coordinate.js';
import _ol_events_Event_ from '../events/Event.js';
import _ol_extent_ from '../extent.js';
import _ol_geom_GeometryType_ from '../geom/GeometryType.js';
import _ol_geom_Point_ from '../geom/Point.js';
import _ol_geom_Polygon_ from '../geom/Polygon.js';
import _ol_interaction_ExtentEventType_ from '../interaction/ExtentEventType.js';
import _ol_interaction_Pointer_ from '../interaction/Pointer.js';
import _ol_layer_Vector_ from '../layer/Vector.js';
import _ol_source_Vector_ from '../source/Vector.js';
import _ol_style_Style_ from '../style/Style.js';
/**
* @classdesc
@@ -29,7 +29,7 @@ goog.require('ol.style.Style');
* @param {olx.interaction.ExtentOptions=} opt_options Options.
* @api
*/
ol.interaction.Extent = function(opt_options) {
var _ol_interaction_Extent_ = function(opt_options) {
var options = opt_options || {};
@@ -81,11 +81,11 @@ ol.interaction.Extent = function(opt_options) {
}
/* Inherit ol.interaction.Pointer */
ol.interaction.Pointer.call(this, {
handleDownEvent: ol.interaction.Extent.handleDownEvent_,
handleDragEvent: ol.interaction.Extent.handleDragEvent_,
handleEvent: ol.interaction.Extent.handleEvent_,
handleUpEvent: ol.interaction.Extent.handleUpEvent_
_ol_interaction_Pointer_.call(this, {
handleDownEvent: _ol_interaction_Extent_.handleDownEvent_,
handleDragEvent: _ol_interaction_Extent_.handleDragEvent_,
handleEvent: _ol_interaction_Extent_.handleEvent_,
handleUpEvent: _ol_interaction_Extent_.handleUpEvent_
});
/**
@@ -93,12 +93,12 @@ ol.interaction.Extent = function(opt_options) {
* @type {ol.layer.Vector}
* @private
*/
this.extentOverlay_ = new ol.layer.Vector({
source: new ol.source.Vector({
this.extentOverlay_ = new _ol_layer_Vector_({
source: new _ol_source_Vector_({
useSpatialIndex: false,
wrapX: !!opt_options.wrapX
}),
style: opt_options.boxStyle ? opt_options.boxStyle : ol.interaction.Extent.getDefaultExtentStyleFunction_(),
style: opt_options.boxStyle ? opt_options.boxStyle : _ol_interaction_Extent_.getDefaultExtentStyleFunction_(),
updateWhileAnimating: true,
updateWhileInteracting: true
});
@@ -108,12 +108,12 @@ ol.interaction.Extent = function(opt_options) {
* @type {ol.layer.Vector}
* @private
*/
this.vertexOverlay_ = new ol.layer.Vector({
source: new ol.source.Vector({
this.vertexOverlay_ = new _ol_layer_Vector_({
source: new _ol_source_Vector_({
useSpatialIndex: false,
wrapX: !!opt_options.wrapX
}),
style: opt_options.pointerStyle ? opt_options.pointerStyle : ol.interaction.Extent.getDefaultPointerStyleFunction_(),
style: opt_options.pointerStyle ? opt_options.pointerStyle : _ol_interaction_Extent_.getDefaultPointerStyleFunction_(),
updateWhileAnimating: true,
updateWhileInteracting: true
});
@@ -123,7 +123,7 @@ ol.interaction.Extent = function(opt_options) {
}
};
ol.inherits(ol.interaction.Extent, ol.interaction.Pointer);
_ol_.inherits(_ol_interaction_Extent_, _ol_interaction_Pointer_);
/**
* @param {ol.MapBrowserEvent} mapBrowserEvent Event.
@@ -131,16 +131,16 @@ ol.inherits(ol.interaction.Extent, ol.interaction.Pointer);
* @this {ol.interaction.Extent}
* @private
*/
ol.interaction.Extent.handleEvent_ = function(mapBrowserEvent) {
if (!(mapBrowserEvent instanceof ol.MapBrowserPointerEvent)) {
_ol_interaction_Extent_.handleEvent_ = function(mapBrowserEvent) {
if (!(mapBrowserEvent instanceof _ol_MapBrowserPointerEvent_)) {
return true;
}
//display pointer (if not dragging)
if (mapBrowserEvent.type == ol.MapBrowserEventType.POINTERMOVE && !this.handlingDownUpSequence) {
if (mapBrowserEvent.type == _ol_MapBrowserEventType_.POINTERMOVE && !this.handlingDownUpSequence) {
this.handlePointerMove_(mapBrowserEvent);
}
//call pointer to determine up/down/drag
ol.interaction.Pointer.handleEvent.call(this, mapBrowserEvent);
_ol_interaction_Pointer_.handleEvent.call(this, mapBrowserEvent);
//return false to stop propagation
return false;
};
@@ -151,7 +151,7 @@ ol.interaction.Extent.handleEvent_ = function(mapBrowserEvent) {
* @this {ol.interaction.Extent}
* @private
*/
ol.interaction.Extent.handleDownEvent_ = function(mapBrowserEvent) {
_ol_interaction_Extent_.handleDownEvent_ = function(mapBrowserEvent) {
var pixel = mapBrowserEvent.pixel;
var map = mapBrowserEvent.map;
@@ -183,15 +183,15 @@ ol.interaction.Extent.handleDownEvent_ = function(mapBrowserEvent) {
//snap to point
if (x !== null && y !== null) {
this.pointerHandler_ = ol.interaction.Extent.getPointHandler_(getOpposingPoint(vertex));
this.pointerHandler_ = _ol_interaction_Extent_.getPointHandler_(getOpposingPoint(vertex));
//snap to edge
} else if (x !== null) {
this.pointerHandler_ = ol.interaction.Extent.getEdgeHandler_(
this.pointerHandler_ = _ol_interaction_Extent_.getEdgeHandler_(
getOpposingPoint([x, extent[1]]),
getOpposingPoint([x, extent[3]])
);
} else if (y !== null) {
this.pointerHandler_ = ol.interaction.Extent.getEdgeHandler_(
this.pointerHandler_ = _ol_interaction_Extent_.getEdgeHandler_(
getOpposingPoint([extent[0], y]),
getOpposingPoint([extent[2], y])
);
@@ -200,7 +200,7 @@ ol.interaction.Extent.handleDownEvent_ = function(mapBrowserEvent) {
} else {
vertex = map.getCoordinateFromPixel(pixel);
this.setExtent([vertex[0], vertex[1], vertex[0], vertex[1]]);
this.pointerHandler_ = ol.interaction.Extent.getPointHandler_(vertex);
this.pointerHandler_ = _ol_interaction_Extent_.getPointHandler_(vertex);
}
return true; //event handled; start downup sequence
};
@@ -211,7 +211,7 @@ ol.interaction.Extent.handleDownEvent_ = function(mapBrowserEvent) {
* @this {ol.interaction.Extent}
* @private
*/
ol.interaction.Extent.handleDragEvent_ = function(mapBrowserEvent) {
_ol_interaction_Extent_.handleDragEvent_ = function(mapBrowserEvent) {
if (this.pointerHandler_) {
var pixelCoordinate = mapBrowserEvent.coordinate;
this.setExtent(this.pointerHandler_(pixelCoordinate));
@@ -226,11 +226,11 @@ ol.interaction.Extent.handleDragEvent_ = function(mapBrowserEvent) {
* @this {ol.interaction.Extent}
* @private
*/
ol.interaction.Extent.handleUpEvent_ = function(mapBrowserEvent) {
_ol_interaction_Extent_.handleUpEvent_ = function(mapBrowserEvent) {
this.pointerHandler_ = null;
//If bbox is zero area, set to null;
var extent = this.getExtent();
if (!extent || ol.extent.getArea(extent) === 0) {
if (!extent || _ol_extent_.getArea(extent) === 0) {
this.setExtent(null);
}
return false; //Stop handling downup sequence
@@ -242,10 +242,10 @@ ol.interaction.Extent.handleUpEvent_ = function(mapBrowserEvent) {
* @return {ol.StyleFunction} Default Extent style
* @private
*/
ol.interaction.Extent.getDefaultExtentStyleFunction_ = function() {
var style = ol.style.Style.createDefaultEditing();
_ol_interaction_Extent_.getDefaultExtentStyleFunction_ = function() {
var style = _ol_style_Style_.createDefaultEditing();
return function(feature, resolution) {
return style[ol.geom.GeometryType.POLYGON];
return style[_ol_geom_GeometryType_.POLYGON];
};
};
@@ -255,10 +255,10 @@ ol.interaction.Extent.getDefaultExtentStyleFunction_ = function() {
* @return {ol.StyleFunction} Default pointer style
* @private
*/
ol.interaction.Extent.getDefaultPointerStyleFunction_ = function() {
var style = ol.style.Style.createDefaultEditing();
_ol_interaction_Extent_.getDefaultPointerStyleFunction_ = function() {
var style = _ol_style_Style_.createDefaultEditing();
return function(feature, resolution) {
return style[ol.geom.GeometryType.POINT];
return style[_ol_geom_GeometryType_.POINT];
};
};
@@ -267,9 +267,9 @@ ol.interaction.Extent.getDefaultPointerStyleFunction_ = function() {
* @returns {function (ol.Coordinate): ol.Extent} event handler
* @private
*/
ol.interaction.Extent.getPointHandler_ = function(fixedPoint) {
_ol_interaction_Extent_.getPointHandler_ = function(fixedPoint) {
return function(point) {
return ol.extent.boundingExtent([fixedPoint, point]);
return _ol_extent_.boundingExtent([fixedPoint, point]);
};
};
@@ -279,14 +279,14 @@ ol.interaction.Extent.getPointHandler_ = function(fixedPoint) {
* @returns {function (ol.Coordinate): ol.Extent|null} event handler
* @private
*/
ol.interaction.Extent.getEdgeHandler_ = function(fixedP1, fixedP2) {
_ol_interaction_Extent_.getEdgeHandler_ = function(fixedP1, fixedP2) {
if (fixedP1[0] == fixedP2[0]) {
return function(point) {
return ol.extent.boundingExtent([fixedP1, [point[0], fixedP2[1]]]);
return _ol_extent_.boundingExtent([fixedP1, [point[0], fixedP2[1]]]);
};
} else if (fixedP1[1] == fixedP2[1]) {
return function(point) {
return ol.extent.boundingExtent([fixedP1, [fixedP2[0], point[1]]]);
return _ol_extent_.boundingExtent([fixedP1, [fixedP2[0], point[1]]]);
};
} else {
return null;
@@ -298,7 +298,7 @@ ol.interaction.Extent.getEdgeHandler_ = function(fixedP1, fixedP2) {
* @returns {Array<Array<ol.Coordinate>>} extent line segments
* @private
*/
ol.interaction.Extent.getSegments_ = function(extent) {
_ol_interaction_Extent_.getSegments_ = function(extent) {
return [
[[extent[0], extent[1]], [extent[0], extent[3]]],
[[extent[0], extent[3]], [extent[2], extent[3]]],
@@ -313,30 +313,30 @@ ol.interaction.Extent.getSegments_ = function(extent) {
* @returns {ol.Coordinate|null} snapped vertex on extent
* @private
*/
ol.interaction.Extent.prototype.snapToVertex_ = function(pixel, map) {
_ol_interaction_Extent_.prototype.snapToVertex_ = function(pixel, map) {
var pixelCoordinate = map.getCoordinateFromPixel(pixel);
var sortByDistance = function(a, b) {
return ol.coordinate.squaredDistanceToSegment(pixelCoordinate, a) -
ol.coordinate.squaredDistanceToSegment(pixelCoordinate, b);
return _ol_coordinate_.squaredDistanceToSegment(pixelCoordinate, a) -
_ol_coordinate_.squaredDistanceToSegment(pixelCoordinate, b);
};
var extent = this.getExtent();
if (extent) {
//convert extents to line segments and find the segment closest to pixelCoordinate
var segments = ol.interaction.Extent.getSegments_(extent);
var segments = _ol_interaction_Extent_.getSegments_(extent);
segments.sort(sortByDistance);
var closestSegment = segments[0];
var vertex = (ol.coordinate.closestOnSegment(pixelCoordinate,
var vertex = (_ol_coordinate_.closestOnSegment(pixelCoordinate,
closestSegment));
var vertexPixel = map.getPixelFromCoordinate(vertex);
//if the distance is within tolerance, snap to the segment
if (ol.coordinate.distance(pixel, vertexPixel) <= this.pixelTolerance_) {
if (_ol_coordinate_.distance(pixel, vertexPixel) <= this.pixelTolerance_) {
//test if we should further snap to a vertex
var pixel1 = map.getPixelFromCoordinate(closestSegment[0]);
var pixel2 = map.getPixelFromCoordinate(closestSegment[1]);
var squaredDist1 = ol.coordinate.squaredDistance(vertexPixel, pixel1);
var squaredDist2 = ol.coordinate.squaredDistance(vertexPixel, pixel2);
var squaredDist1 = _ol_coordinate_.squaredDistance(vertexPixel, pixel1);
var squaredDist2 = _ol_coordinate_.squaredDistance(vertexPixel, pixel2);
var dist = Math.sqrt(Math.min(squaredDist1, squaredDist2));
this.snappedToVertex_ = dist <= this.pixelTolerance_;
if (this.snappedToVertex_) {
@@ -353,7 +353,7 @@ ol.interaction.Extent.prototype.snapToVertex_ = function(pixel, map) {
* @param {ol.MapBrowserEvent} mapBrowserEvent pointer move event
* @private
*/
ol.interaction.Extent.prototype.handlePointerMove_ = function(mapBrowserEvent) {
_ol_interaction_Extent_.prototype.handlePointerMove_ = function(mapBrowserEvent) {
var pixel = mapBrowserEvent.pixel;
var map = mapBrowserEvent.map;
@@ -369,14 +369,14 @@ ol.interaction.Extent.prototype.handlePointerMove_ = function(mapBrowserEvent) {
* @returns {ol.Feature} extent as featrue
* @private
*/
ol.interaction.Extent.prototype.createOrUpdateExtentFeature_ = function(extent) {
_ol_interaction_Extent_.prototype.createOrUpdateExtentFeature_ = function(extent) {
var extentFeature = this.extentFeature_;
if (!extentFeature) {
if (!extent) {
extentFeature = new ol.Feature({});
extentFeature = new _ol_Feature_({});
} else {
extentFeature = new ol.Feature(ol.geom.Polygon.fromExtent(extent));
extentFeature = new _ol_Feature_(_ol_geom_Polygon_.fromExtent(extent));
}
this.extentFeature_ = extentFeature;
this.extentOverlay_.getSource().addFeature(extentFeature);
@@ -384,7 +384,7 @@ ol.interaction.Extent.prototype.createOrUpdateExtentFeature_ = function(extent)
if (!extent) {
extentFeature.setGeometry(undefined);
} else {
extentFeature.setGeometry(ol.geom.Polygon.fromExtent(extent));
extentFeature.setGeometry(_ol_geom_Polygon_.fromExtent(extent));
}
}
return extentFeature;
@@ -396,10 +396,10 @@ ol.interaction.Extent.prototype.createOrUpdateExtentFeature_ = function(extent)
* @returns {ol.Feature} vertex as feature
* @private
*/
ol.interaction.Extent.prototype.createOrUpdatePointerFeature_ = function(vertex) {
_ol_interaction_Extent_.prototype.createOrUpdatePointerFeature_ = function(vertex) {
var vertexFeature = this.vertexFeature_;
if (!vertexFeature) {
vertexFeature = new ol.Feature(new ol.geom.Point(vertex));
vertexFeature = new _ol_Feature_(new _ol_geom_Point_(vertex));
this.vertexFeature_ = vertexFeature;
this.vertexOverlay_.getSource().addFeature(vertexFeature);
} else {
@@ -413,10 +413,10 @@ ol.interaction.Extent.prototype.createOrUpdatePointerFeature_ = function(vertex)
/**
* @inheritDoc
*/
ol.interaction.Extent.prototype.setMap = function(map) {
_ol_interaction_Extent_.prototype.setMap = function(map) {
this.extentOverlay_.setMap(map);
this.vertexOverlay_.setMap(map);
ol.interaction.Pointer.prototype.setMap.call(this, map);
_ol_interaction_Pointer_.prototype.setMap.call(this, map);
};
/**
@@ -425,7 +425,7 @@ ol.interaction.Extent.prototype.setMap = function(map) {
* @return {ol.Extent} Drawn extent in the view projection.
* @api
*/
ol.interaction.Extent.prototype.getExtent = function() {
_ol_interaction_Extent_.prototype.getExtent = function() {
return this.extent_;
};
@@ -435,11 +435,11 @@ ol.interaction.Extent.prototype.getExtent = function() {
* @param {ol.Extent} extent Extent
* @api
*/
ol.interaction.Extent.prototype.setExtent = function(extent) {
_ol_interaction_Extent_.prototype.setExtent = function(extent) {
//Null extent means no bbox
this.extent_ = extent ? extent : null;
this.createOrUpdateExtentFeature_(extent);
this.dispatchEvent(new ol.interaction.Extent.Event(this.extent_));
this.dispatchEvent(new _ol_interaction_Extent_.Event(this.extent_));
};
@@ -453,8 +453,8 @@ ol.interaction.Extent.prototype.setExtent = function(extent) {
* @param {ol.Extent} extent the new extent
* @extends {ol.events.Event}
*/
ol.interaction.Extent.Event = function(extent) {
ol.events.Event.call(this, ol.interaction.ExtentEventType.EXTENTCHANGED);
_ol_interaction_Extent_.Event = function(extent) {
_ol_events_Event_.call(this, _ol_interaction_ExtentEventType_.EXTENTCHANGED);
/**
* The current extent.
@@ -464,4 +464,5 @@ ol.interaction.Extent.Event = function(extent) {
this.extent = extent;
};
ol.inherits(ol.interaction.Extent.Event, ol.events.Event);
_ol_.inherits(_ol_interaction_Extent_.Event, _ol_events_Event_);
export default _ol_interaction_Extent_;

View File

@@ -1,10 +1,10 @@
goog.provide('ol.interaction.ExtentEventType');
/**
* @module ol/interaction/ExtentEventType
*/
/**
* @enum {string}
*/
ol.interaction.ExtentEventType = {
var _ol_interaction_ExtentEventType_ = {
/**
* Triggered after the extent is changed
* @event ol.interaction.Extent.Event#extentchanged
@@ -12,3 +12,5 @@ ol.interaction.ExtentEventType = {
*/
EXTENTCHANGED: 'extentchanged'
};
export default _ol_interaction_ExtentEventType_;

View File

@@ -1,13 +1,13 @@
/**
* @module ol/interaction/Interaction
*/
// FIXME factor out key precondition (shift et. al)
goog.provide('ol.interaction.Interaction');
goog.require('ol');
goog.require('ol.Object');
goog.require('ol.easing');
goog.require('ol.interaction.Property');
goog.require('ol.math');
import _ol_ from '../index.js';
import _ol_Object_ from '../Object.js';
import _ol_easing_ from '../easing.js';
import _ol_interaction_Property_ from '../interaction/Property.js';
import _ol_math_ from '../math.js';
/**
* @classdesc
@@ -26,9 +26,9 @@ goog.require('ol.math');
* @extends {ol.Object}
* @api
*/
ol.interaction.Interaction = function(options) {
var _ol_interaction_Interaction_ = function(options) {
ol.Object.call(this);
_ol_Object_.call(this);
/**
* @private
@@ -44,7 +44,8 @@ ol.interaction.Interaction = function(options) {
this.handleEvent = options.handleEvent;
};
ol.inherits(ol.interaction.Interaction, ol.Object);
_ol_.inherits(_ol_interaction_Interaction_, _ol_Object_);
/**
@@ -53,9 +54,10 @@ ol.inherits(ol.interaction.Interaction, ol.Object);
* @observable
* @api
*/
ol.interaction.Interaction.prototype.getActive = function() {
return /** @type {boolean} */ (
this.get(ol.interaction.Property.ACTIVE));
_ol_interaction_Interaction_.prototype.getActive = function() {
return (
/** @type {boolean} */ this.get(_ol_interaction_Property_.ACTIVE)
);
};
@@ -64,7 +66,7 @@ ol.interaction.Interaction.prototype.getActive = function() {
* @return {ol.PluggableMap} Map.
* @api
*/
ol.interaction.Interaction.prototype.getMap = function() {
_ol_interaction_Interaction_.prototype.getMap = function() {
return this.map_;
};
@@ -75,8 +77,8 @@ ol.interaction.Interaction.prototype.getMap = function() {
* @observable
* @api
*/
ol.interaction.Interaction.prototype.setActive = function(active) {
this.set(ol.interaction.Property.ACTIVE, active);
_ol_interaction_Interaction_.prototype.setActive = function(active) {
this.set(_ol_interaction_Property_.ACTIVE, active);
};
@@ -86,7 +88,7 @@ ol.interaction.Interaction.prototype.setActive = function(active) {
* the map here.
* @param {ol.PluggableMap} map Map.
*/
ol.interaction.Interaction.prototype.setMap = function(map) {
_ol_interaction_Interaction_.prototype.setMap = function(map) {
this.map_ = map;
};
@@ -96,7 +98,7 @@ ol.interaction.Interaction.prototype.setMap = function(map) {
* @param {ol.Coordinate} delta Delta.
* @param {number=} opt_duration Duration.
*/
ol.interaction.Interaction.pan = function(view, delta, opt_duration) {
_ol_interaction_Interaction_.pan = function(view, delta, opt_duration) {
var currentCenter = view.getCenter();
if (currentCenter) {
var center = view.constrainCenter(
@@ -104,7 +106,7 @@ ol.interaction.Interaction.pan = function(view, delta, opt_duration) {
if (opt_duration) {
view.animate({
duration: opt_duration,
easing: ol.easing.linear,
easing: _ol_easing_.linear,
center: center
});
} else {
@@ -120,9 +122,9 @@ ol.interaction.Interaction.pan = function(view, delta, opt_duration) {
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
* @param {number=} opt_duration Duration.
*/
ol.interaction.Interaction.rotate = function(view, rotation, opt_anchor, opt_duration) {
_ol_interaction_Interaction_.rotate = function(view, rotation, opt_anchor, opt_duration) {
rotation = view.constrainRotation(rotation, 0);
ol.interaction.Interaction.rotateWithoutConstraints(
_ol_interaction_Interaction_.rotateWithoutConstraints(
view, rotation, opt_anchor, opt_duration);
};
@@ -133,7 +135,7 @@ ol.interaction.Interaction.rotate = function(view, rotation, opt_anchor, opt_dur
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
* @param {number=} opt_duration Duration.
*/
ol.interaction.Interaction.rotateWithoutConstraints = function(view, rotation, opt_anchor, opt_duration) {
_ol_interaction_Interaction_.rotateWithoutConstraints = function(view, rotation, opt_anchor, opt_duration) {
if (rotation !== undefined) {
var currentRotation = view.getRotation();
var currentCenter = view.getCenter();
@@ -142,7 +144,7 @@ ol.interaction.Interaction.rotateWithoutConstraints = function(view, rotation, o
rotation: rotation,
anchor: opt_anchor,
duration: opt_duration,
easing: ol.easing.easeOut
easing: _ol_easing_.easeOut
});
} else {
view.rotate(rotation, opt_anchor);
@@ -165,9 +167,9 @@ ol.interaction.Interaction.rotateWithoutConstraints = function(view, rotation, o
* will select the nearest resolution. If not defined 0 is
* assumed.
*/
ol.interaction.Interaction.zoom = function(view, resolution, opt_anchor, opt_duration, opt_direction) {
_ol_interaction_Interaction_.zoom = function(view, resolution, opt_anchor, opt_duration, opt_direction) {
resolution = view.constrainResolution(resolution, 0, opt_direction);
ol.interaction.Interaction.zoomWithoutConstraints(
_ol_interaction_Interaction_.zoomWithoutConstraints(
view, resolution, opt_anchor, opt_duration);
};
@@ -178,13 +180,13 @@ ol.interaction.Interaction.zoom = function(view, resolution, opt_anchor, opt_dur
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
* @param {number=} opt_duration Duration.
*/
ol.interaction.Interaction.zoomByDelta = function(view, delta, opt_anchor, opt_duration) {
_ol_interaction_Interaction_.zoomByDelta = function(view, delta, opt_anchor, opt_duration) {
var currentResolution = view.getResolution();
var resolution = view.constrainResolution(currentResolution, delta, 0);
if (resolution !== undefined) {
var resolutions = view.getResolutions();
resolution = ol.math.clamp(
resolution = _ol_math_.clamp(
resolution,
view.getMinResolution() || resolutions[resolutions.length - 1],
view.getMaxResolution() || resolutions[0]);
@@ -206,7 +208,7 @@ ol.interaction.Interaction.zoomByDelta = function(view, delta, opt_anchor, opt_d
];
}
ol.interaction.Interaction.zoomWithoutConstraints(
_ol_interaction_Interaction_.zoomWithoutConstraints(
view, resolution, opt_anchor, opt_duration);
};
@@ -217,7 +219,7 @@ ol.interaction.Interaction.zoomByDelta = function(view, delta, opt_anchor, opt_d
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
* @param {number=} opt_duration Duration.
*/
ol.interaction.Interaction.zoomWithoutConstraints = function(view, resolution, opt_anchor, opt_duration) {
_ol_interaction_Interaction_.zoomWithoutConstraints = function(view, resolution, opt_anchor, opt_duration) {
if (resolution) {
var currentResolution = view.getResolution();
var currentCenter = view.getCenter();
@@ -227,7 +229,7 @@ ol.interaction.Interaction.zoomWithoutConstraints = function(view, resolution, o
resolution: resolution,
anchor: opt_anchor,
duration: opt_duration,
easing: ol.easing.easeOut
easing: _ol_easing_.easeOut
});
} else {
if (opt_anchor) {
@@ -238,3 +240,4 @@ ol.interaction.Interaction.zoomWithoutConstraints = function(view, resolution, o
}
}
};
export default _ol_interaction_Interaction_;

View File

@@ -1,12 +1,12 @@
goog.provide('ol.interaction.KeyboardPan');
goog.require('ol');
goog.require('ol.coordinate');
goog.require('ol.events.EventType');
goog.require('ol.events.KeyCode');
goog.require('ol.events.condition');
goog.require('ol.interaction.Interaction');
/**
* @module ol/interaction/KeyboardPan
*/
import _ol_ from '../index.js';
import _ol_coordinate_ from '../coordinate.js';
import _ol_events_EventType_ from '../events/EventType.js';
import _ol_events_KeyCode_ from '../events/KeyCode.js';
import _ol_events_condition_ from '../events/condition.js';
import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
/**
* @classdesc
@@ -25,10 +25,10 @@ goog.require('ol.interaction.Interaction');
* @param {olx.interaction.KeyboardPanOptions=} opt_options Options.
* @api
*/
ol.interaction.KeyboardPan = function(opt_options) {
var _ol_interaction_KeyboardPan_ = function(opt_options) {
ol.interaction.Interaction.call(this, {
handleEvent: ol.interaction.KeyboardPan.handleEvent
_ol_interaction_Interaction_.call(this, {
handleEvent: _ol_interaction_KeyboardPan_.handleEvent
});
var options = opt_options || {};
@@ -39,8 +39,8 @@ ol.interaction.KeyboardPan = function(opt_options) {
* @return {boolean} Combined condition result.
*/
this.defaultCondition_ = function(mapBrowserEvent) {
return ol.events.condition.noModifierKeys(mapBrowserEvent) &&
ol.events.condition.targetNotEditable(mapBrowserEvent);
return _ol_events_condition_.noModifierKeys(mapBrowserEvent) &&
_ol_events_condition_.targetNotEditable(mapBrowserEvent);
};
/**
@@ -64,7 +64,8 @@ ol.interaction.KeyboardPan = function(opt_options) {
options.pixelDelta : 128;
};
ol.inherits(ol.interaction.KeyboardPan, ol.interaction.Interaction);
_ol_.inherits(_ol_interaction_KeyboardPan_, _ol_interaction_Interaction_);
/**
* Handles the {@link ol.MapBrowserEvent map browser event} if it was a
@@ -75,35 +76,36 @@ ol.inherits(ol.interaction.KeyboardPan, ol.interaction.Interaction);
* @this {ol.interaction.KeyboardPan}
* @api
*/
ol.interaction.KeyboardPan.handleEvent = function(mapBrowserEvent) {
_ol_interaction_KeyboardPan_.handleEvent = function(mapBrowserEvent) {
var stopEvent = false;
if (mapBrowserEvent.type == ol.events.EventType.KEYDOWN) {
if (mapBrowserEvent.type == _ol_events_EventType_.KEYDOWN) {
var keyEvent = mapBrowserEvent.originalEvent;
var keyCode = keyEvent.keyCode;
if (this.condition_(mapBrowserEvent) &&
(keyCode == ol.events.KeyCode.DOWN ||
keyCode == ol.events.KeyCode.LEFT ||
keyCode == ol.events.KeyCode.RIGHT ||
keyCode == ol.events.KeyCode.UP)) {
(keyCode == _ol_events_KeyCode_.DOWN ||
keyCode == _ol_events_KeyCode_.LEFT ||
keyCode == _ol_events_KeyCode_.RIGHT ||
keyCode == _ol_events_KeyCode_.UP)) {
var map = mapBrowserEvent.map;
var view = map.getView();
var mapUnitsDelta = view.getResolution() * this.pixelDelta_;
var deltaX = 0, deltaY = 0;
if (keyCode == ol.events.KeyCode.DOWN) {
if (keyCode == _ol_events_KeyCode_.DOWN) {
deltaY = -mapUnitsDelta;
} else if (keyCode == ol.events.KeyCode.LEFT) {
} else if (keyCode == _ol_events_KeyCode_.LEFT) {
deltaX = -mapUnitsDelta;
} else if (keyCode == ol.events.KeyCode.RIGHT) {
} else if (keyCode == _ol_events_KeyCode_.RIGHT) {
deltaX = mapUnitsDelta;
} else {
deltaY = mapUnitsDelta;
}
var delta = [deltaX, deltaY];
ol.coordinate.rotate(delta, view.getRotation());
ol.interaction.Interaction.pan(view, delta, this.duration_);
_ol_coordinate_.rotate(delta, view.getRotation());
_ol_interaction_Interaction_.pan(view, delta, this.duration_);
mapBrowserEvent.preventDefault();
stopEvent = true;
}
}
return !stopEvent;
};
export default _ol_interaction_KeyboardPan_;

View File

@@ -1,10 +1,10 @@
goog.provide('ol.interaction.KeyboardZoom');
goog.require('ol');
goog.require('ol.events.EventType');
goog.require('ol.events.condition');
goog.require('ol.interaction.Interaction');
/**
* @module ol/interaction/KeyboardZoom
*/
import _ol_ from '../index.js';
import _ol_events_EventType_ from '../events/EventType.js';
import _ol_events_condition_ from '../events/condition.js';
import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
/**
* @classdesc
@@ -23,10 +23,10 @@ goog.require('ol.interaction.Interaction');
* @extends {ol.interaction.Interaction}
* @api
*/
ol.interaction.KeyboardZoom = function(opt_options) {
var _ol_interaction_KeyboardZoom_ = function(opt_options) {
ol.interaction.Interaction.call(this, {
handleEvent: ol.interaction.KeyboardZoom.handleEvent
_ol_interaction_Interaction_.call(this, {
handleEvent: _ol_interaction_KeyboardZoom_.handleEvent
});
var options = opt_options ? opt_options : {};
@@ -36,7 +36,7 @@ ol.interaction.KeyboardZoom = function(opt_options) {
* @type {ol.EventsConditionType}
*/
this.condition_ = options.condition ? options.condition :
ol.events.condition.targetNotEditable;
_ol_events_condition_.targetNotEditable;
/**
* @private
@@ -51,7 +51,8 @@ ol.interaction.KeyboardZoom = function(opt_options) {
this.duration_ = options.duration !== undefined ? options.duration : 100;
};
ol.inherits(ol.interaction.KeyboardZoom, ol.interaction.Interaction);
_ol_.inherits(_ol_interaction_KeyboardZoom_, _ol_interaction_Interaction_);
/**
@@ -63,10 +64,10 @@ ol.inherits(ol.interaction.KeyboardZoom, ol.interaction.Interaction);
* @this {ol.interaction.KeyboardZoom}
* @api
*/
ol.interaction.KeyboardZoom.handleEvent = function(mapBrowserEvent) {
_ol_interaction_KeyboardZoom_.handleEvent = function(mapBrowserEvent) {
var stopEvent = false;
if (mapBrowserEvent.type == ol.events.EventType.KEYDOWN ||
mapBrowserEvent.type == ol.events.EventType.KEYPRESS) {
if (mapBrowserEvent.type == _ol_events_EventType_.KEYDOWN ||
mapBrowserEvent.type == _ol_events_EventType_.KEYPRESS) {
var keyEvent = mapBrowserEvent.originalEvent;
var charCode = keyEvent.charCode;
if (this.condition_(mapBrowserEvent) &&
@@ -74,7 +75,7 @@ ol.interaction.KeyboardZoom.handleEvent = function(mapBrowserEvent) {
var map = mapBrowserEvent.map;
var delta = (charCode == '+'.charCodeAt(0)) ? this.delta_ : -this.delta_;
var view = map.getView();
ol.interaction.Interaction.zoomByDelta(
_ol_interaction_Interaction_.zoomByDelta(
view, delta, undefined, this.duration_);
mapBrowserEvent.preventDefault();
stopEvent = true;
@@ -82,3 +83,4 @@ ol.interaction.KeyboardZoom.handleEvent = function(mapBrowserEvent) {
}
return !stopEvent;
};
export default _ol_interaction_KeyboardZoom_;

View File

@@ -1,27 +1,28 @@
goog.provide('ol.interaction.Modify');
goog.require('ol');
goog.require('ol.Collection');
goog.require('ol.CollectionEventType');
goog.require('ol.Feature');
goog.require('ol.MapBrowserEventType');
goog.require('ol.MapBrowserPointerEvent');
goog.require('ol.array');
goog.require('ol.coordinate');
goog.require('ol.events');
goog.require('ol.events.Event');
goog.require('ol.events.EventType');
goog.require('ol.events.condition');
goog.require('ol.extent');
goog.require('ol.geom.GeometryType');
goog.require('ol.geom.Point');
goog.require('ol.interaction.ModifyEventType');
goog.require('ol.interaction.Pointer');
goog.require('ol.layer.Vector');
goog.require('ol.source.Vector');
goog.require('ol.source.VectorEventType');
goog.require('ol.structs.RBush');
goog.require('ol.style.Style');
/**
* @module ol/interaction/Modify
*/
import _ol_ from '../index.js';
import _ol_Collection_ from '../Collection.js';
import _ol_CollectionEventType_ from '../CollectionEventType.js';
import _ol_Feature_ from '../Feature.js';
import _ol_MapBrowserEventType_ from '../MapBrowserEventType.js';
import _ol_MapBrowserPointerEvent_ from '../MapBrowserPointerEvent.js';
import _ol_array_ from '../array.js';
import _ol_coordinate_ from '../coordinate.js';
import _ol_events_ from '../events.js';
import _ol_events_Event_ from '../events/Event.js';
import _ol_events_EventType_ from '../events/EventType.js';
import _ol_events_condition_ from '../events/condition.js';
import _ol_extent_ from '../extent.js';
import _ol_geom_GeometryType_ from '../geom/GeometryType.js';
import _ol_geom_Point_ from '../geom/Point.js';
import _ol_interaction_ModifyEventType_ from '../interaction/ModifyEventType.js';
import _ol_interaction_Pointer_ from '../interaction/Pointer.js';
import _ol_layer_Vector_ from '../layer/Vector.js';
import _ol_source_Vector_ from '../source/Vector.js';
import _ol_source_VectorEventType_ from '../source/VectorEventType.js';
import _ol_structs_RBush_ from '../structs/RBush.js';
import _ol_style_Style_ from '../style/Style.js';
/**
* @classdesc
@@ -42,13 +43,13 @@ goog.require('ol.style.Style');
* @fires ol.interaction.Modify.Event
* @api
*/
ol.interaction.Modify = function(options) {
var _ol_interaction_Modify_ = function(options) {
ol.interaction.Pointer.call(this, {
handleDownEvent: ol.interaction.Modify.handleDownEvent_,
handleDragEvent: ol.interaction.Modify.handleDragEvent_,
handleEvent: ol.interaction.Modify.handleEvent,
handleUpEvent: ol.interaction.Modify.handleUpEvent_
_ol_interaction_Pointer_.call(this, {
handleDownEvent: _ol_interaction_Modify_.handleDownEvent_,
handleDragEvent: _ol_interaction_Modify_.handleDragEvent_,
handleEvent: _ol_interaction_Modify_.handleEvent,
handleUpEvent: _ol_interaction_Modify_.handleUpEvent_
});
/**
@@ -56,7 +57,7 @@ ol.interaction.Modify = function(options) {
* @type {ol.EventsConditionType}
*/
this.condition_ = options.condition ?
options.condition : ol.events.condition.primaryAction;
options.condition : _ol_events_condition_.primaryAction;
/**
@@ -65,8 +66,8 @@ ol.interaction.Modify = function(options) {
* @return {boolean} Combined condition result.
*/
this.defaultDeleteCondition_ = function(mapBrowserEvent) {
return ol.events.condition.altKeyOnly(mapBrowserEvent) &&
ol.events.condition.singleClick(mapBrowserEvent);
return _ol_events_condition_.altKeyOnly(mapBrowserEvent) &&
_ol_events_condition_.singleClick(mapBrowserEvent);
};
/**
@@ -81,7 +82,7 @@ ol.interaction.Modify = function(options) {
* @private
*/
this.insertVertexCondition_ = options.insertVertexCondition ?
options.insertVertexCondition : ol.events.condition.always;
options.insertVertexCondition : _ol_events_condition_.always;
/**
* Editing vertex.
@@ -122,7 +123,7 @@ ol.interaction.Modify = function(options) {
* @type {ol.structs.RBush.<ol.ModifySegmentDataType>}
* @private
*/
this.rBush_ = new ol.structs.RBush();
this.rBush_ = new _ol_structs_RBush_();
/**
* @type {number}
@@ -156,13 +157,13 @@ ol.interaction.Modify = function(options) {
* @type {ol.layer.Vector}
* @private
*/
this.overlay_ = new ol.layer.Vector({
source: new ol.source.Vector({
this.overlay_ = new _ol_layer_Vector_({
source: new _ol_source_Vector_({
useSpatialIndex: false,
wrapX: !!options.wrapX
}),
style: options.style ? options.style :
ol.interaction.Modify.getDefaultStyleFunction(),
_ol_interaction_Modify_.getDefaultStyleFunction(),
updateWhileAnimating: true,
updateWhileInteracting: true
});
@@ -194,10 +195,10 @@ ol.interaction.Modify = function(options) {
var features;
if (options.source) {
this.source_ = options.source;
features = new ol.Collection(this.source_.getFeatures());
ol.events.listen(this.source_, ol.source.VectorEventType.ADDFEATURE,
features = new _ol_Collection_(this.source_.getFeatures());
_ol_events_.listen(this.source_, _ol_source_VectorEventType_.ADDFEATURE,
this.handleSourceAdd_, this);
ol.events.listen(this.source_, ol.source.VectorEventType.REMOVEFEATURE,
_ol_events_.listen(this.source_, _ol_source_VectorEventType_.REMOVEFEATURE,
this.handleSourceRemove_, this);
} else {
features = options.features;
@@ -213,9 +214,9 @@ ol.interaction.Modify = function(options) {
this.features_ = features;
this.features_.forEach(this.addFeature_, this);
ol.events.listen(this.features_, ol.CollectionEventType.ADD,
_ol_events_.listen(this.features_, _ol_CollectionEventType_.ADD,
this.handleFeatureAdd_, this);
ol.events.listen(this.features_, ol.CollectionEventType.REMOVE,
_ol_events_.listen(this.features_, _ol_CollectionEventType_.REMOVE,
this.handleFeatureRemove_, this);
/**
@@ -225,27 +226,28 @@ ol.interaction.Modify = function(options) {
this.lastPointerEvent_ = null;
};
ol.inherits(ol.interaction.Modify, ol.interaction.Pointer);
_ol_.inherits(_ol_interaction_Modify_, _ol_interaction_Pointer_);
/**
* @define {number} The segment index assigned to a circle's center when
* breaking up a cicrle into ModifySegmentDataType segments.
*/
ol.interaction.Modify.MODIFY_SEGMENT_CIRCLE_CENTER_INDEX = 0;
_ol_interaction_Modify_.MODIFY_SEGMENT_CIRCLE_CENTER_INDEX = 0;
/**
* @define {number} The segment index assigned to a circle's circumference when
* breaking up a circle into ModifySegmentDataType segments.
*/
ol.interaction.Modify.MODIFY_SEGMENT_CIRCLE_CIRCUMFERENCE_INDEX = 1;
_ol_interaction_Modify_.MODIFY_SEGMENT_CIRCLE_CIRCUMFERENCE_INDEX = 1;
/**
* @param {ol.Feature} feature Feature.
* @private
*/
ol.interaction.Modify.prototype.addFeature_ = function(feature) {
_ol_interaction_Modify_.prototype.addFeature_ = function(feature) {
var geometry = feature.getGeometry();
if (geometry && geometry.getType() in this.SEGMENT_WRITERS_) {
this.SEGMENT_WRITERS_[geometry.getType()].call(this, feature, geometry);
@@ -254,7 +256,7 @@ ol.interaction.Modify.prototype.addFeature_ = function(feature) {
if (map && map.isRendered() && this.getActive()) {
this.handlePointerAtPixel_(this.lastPixel_, map);
}
ol.events.listen(feature, ol.events.EventType.CHANGE,
_ol_events_.listen(feature, _ol_events_EventType_.CHANGE,
this.handleFeatureChange_, this);
};
@@ -263,11 +265,11 @@ ol.interaction.Modify.prototype.addFeature_ = function(feature) {
* @param {ol.MapBrowserPointerEvent} evt Map browser event
* @private
*/
ol.interaction.Modify.prototype.willModifyFeatures_ = function(evt) {
_ol_interaction_Modify_.prototype.willModifyFeatures_ = function(evt) {
if (!this.modified_) {
this.modified_ = true;
this.dispatchEvent(new ol.interaction.Modify.Event(
ol.interaction.ModifyEventType.MODIFYSTART, this.features_, evt));
this.dispatchEvent(new _ol_interaction_Modify_.Event(
_ol_interaction_ModifyEventType_.MODIFYSTART, this.features_, evt));
}
};
@@ -276,7 +278,7 @@ ol.interaction.Modify.prototype.willModifyFeatures_ = function(evt) {
* @param {ol.Feature} feature Feature.
* @private
*/
ol.interaction.Modify.prototype.removeFeature_ = function(feature) {
_ol_interaction_Modify_.prototype.removeFeature_ = function(feature) {
this.removeFeatureSegmentData_(feature);
// Remove the vertex feature if the collection of canditate features
// is empty.
@@ -284,7 +286,7 @@ ol.interaction.Modify.prototype.removeFeature_ = function(feature) {
this.overlay_.getSource().removeFeature(this.vertexFeature_);
this.vertexFeature_ = null;
}
ol.events.unlisten(feature, ol.events.EventType.CHANGE,
_ol_events_.unlisten(feature, _ol_events_EventType_.CHANGE,
this.handleFeatureChange_, this);
};
@@ -293,7 +295,7 @@ ol.interaction.Modify.prototype.removeFeature_ = function(feature) {
* @param {ol.Feature} feature Feature.
* @private
*/
ol.interaction.Modify.prototype.removeFeatureSegmentData_ = function(feature) {
_ol_interaction_Modify_.prototype.removeFeatureSegmentData_ = function(feature) {
var rBush = this.rBush_;
var /** @type {Array.<ol.ModifySegmentDataType>} */ nodesToRemove = [];
rBush.forEach(
@@ -314,21 +316,21 @@ ol.interaction.Modify.prototype.removeFeatureSegmentData_ = function(feature) {
/**
* @inheritDoc
*/
ol.interaction.Modify.prototype.setActive = function(active) {
_ol_interaction_Modify_.prototype.setActive = function(active) {
if (this.vertexFeature_ && !active) {
this.overlay_.getSource().removeFeature(this.vertexFeature_);
this.vertexFeature_ = null;
}
ol.interaction.Pointer.prototype.setActive.call(this, active);
_ol_interaction_Pointer_.prototype.setActive.call(this, active);
};
/**
* @inheritDoc
*/
ol.interaction.Modify.prototype.setMap = function(map) {
_ol_interaction_Modify_.prototype.setMap = function(map) {
this.overlay_.setMap(map);
ol.interaction.Pointer.prototype.setMap.call(this, map);
_ol_interaction_Pointer_.prototype.setMap.call(this, map);
};
@@ -336,7 +338,7 @@ ol.interaction.Modify.prototype.setMap = function(map) {
* @param {ol.source.Vector.Event} event Event.
* @private
*/
ol.interaction.Modify.prototype.handleSourceAdd_ = function(event) {
_ol_interaction_Modify_.prototype.handleSourceAdd_ = function(event) {
if (event.feature) {
this.features_.push(event.feature);
}
@@ -347,7 +349,7 @@ ol.interaction.Modify.prototype.handleSourceAdd_ = function(event) {
* @param {ol.source.Vector.Event} event Event.
* @private
*/
ol.interaction.Modify.prototype.handleSourceRemove_ = function(event) {
_ol_interaction_Modify_.prototype.handleSourceRemove_ = function(event) {
if (event.feature) {
this.features_.remove(event.feature);
}
@@ -358,7 +360,7 @@ ol.interaction.Modify.prototype.handleSourceRemove_ = function(event) {
* @param {ol.Collection.Event} evt Event.
* @private
*/
ol.interaction.Modify.prototype.handleFeatureAdd_ = function(evt) {
_ol_interaction_Modify_.prototype.handleFeatureAdd_ = function(evt) {
this.addFeature_(/** @type {ol.Feature} */ (evt.element));
};
@@ -367,7 +369,7 @@ ol.interaction.Modify.prototype.handleFeatureAdd_ = function(evt) {
* @param {ol.events.Event} evt Event.
* @private
*/
ol.interaction.Modify.prototype.handleFeatureChange_ = function(evt) {
_ol_interaction_Modify_.prototype.handleFeatureChange_ = function(evt) {
if (!this.changingFeature_) {
var feature = /** @type {ol.Feature} */ (evt.target);
this.removeFeature_(feature);
@@ -380,7 +382,7 @@ ol.interaction.Modify.prototype.handleFeatureChange_ = function(evt) {
* @param {ol.Collection.Event} evt Event.
* @private
*/
ol.interaction.Modify.prototype.handleFeatureRemove_ = function(evt) {
_ol_interaction_Modify_.prototype.handleFeatureRemove_ = function(evt) {
var feature = /** @type {ol.Feature} */ (evt.element);
this.removeFeature_(feature);
};
@@ -391,7 +393,7 @@ ol.interaction.Modify.prototype.handleFeatureRemove_ = function(evt) {
* @param {ol.geom.Point} geometry Geometry.
* @private
*/
ol.interaction.Modify.prototype.writePointGeometry_ = function(feature, geometry) {
_ol_interaction_Modify_.prototype.writePointGeometry_ = function(feature, geometry) {
var coordinates = geometry.getCoordinates();
var segmentData = /** @type {ol.ModifySegmentDataType} */ ({
feature: feature,
@@ -407,7 +409,7 @@ ol.interaction.Modify.prototype.writePointGeometry_ = function(feature, geometry
* @param {ol.geom.MultiPoint} geometry Geometry.
* @private
*/
ol.interaction.Modify.prototype.writeMultiPointGeometry_ = function(feature, geometry) {
_ol_interaction_Modify_.prototype.writeMultiPointGeometry_ = function(feature, geometry) {
var points = geometry.getCoordinates();
var coordinates, i, ii, segmentData;
for (i = 0, ii = points.length; i < ii; ++i) {
@@ -429,7 +431,7 @@ ol.interaction.Modify.prototype.writeMultiPointGeometry_ = function(feature, geo
* @param {ol.geom.LineString} geometry Geometry.
* @private
*/
ol.interaction.Modify.prototype.writeLineStringGeometry_ = function(feature, geometry) {
_ol_interaction_Modify_.prototype.writeLineStringGeometry_ = function(feature, geometry) {
var coordinates = geometry.getCoordinates();
var i, ii, segment, segmentData;
for (i = 0, ii = coordinates.length - 1; i < ii; ++i) {
@@ -440,7 +442,7 @@ ol.interaction.Modify.prototype.writeLineStringGeometry_ = function(feature, geo
index: i,
segment: segment
});
this.rBush_.insert(ol.extent.boundingExtent(segment), segmentData);
this.rBush_.insert(_ol_extent_.boundingExtent(segment), segmentData);
}
};
@@ -450,7 +452,7 @@ ol.interaction.Modify.prototype.writeLineStringGeometry_ = function(feature, geo
* @param {ol.geom.MultiLineString} geometry Geometry.
* @private
*/
ol.interaction.Modify.prototype.writeMultiLineStringGeometry_ = function(feature, geometry) {
_ol_interaction_Modify_.prototype.writeMultiLineStringGeometry_ = function(feature, geometry) {
var lines = geometry.getCoordinates();
var coordinates, i, ii, j, jj, segment, segmentData;
for (j = 0, jj = lines.length; j < jj; ++j) {
@@ -464,7 +466,7 @@ ol.interaction.Modify.prototype.writeMultiLineStringGeometry_ = function(feature
index: i,
segment: segment
});
this.rBush_.insert(ol.extent.boundingExtent(segment), segmentData);
this.rBush_.insert(_ol_extent_.boundingExtent(segment), segmentData);
}
}
};
@@ -475,7 +477,7 @@ ol.interaction.Modify.prototype.writeMultiLineStringGeometry_ = function(feature
* @param {ol.geom.Polygon} geometry Geometry.
* @private
*/
ol.interaction.Modify.prototype.writePolygonGeometry_ = function(feature, geometry) {
_ol_interaction_Modify_.prototype.writePolygonGeometry_ = function(feature, geometry) {
var rings = geometry.getCoordinates();
var coordinates, i, ii, j, jj, segment, segmentData;
for (j = 0, jj = rings.length; j < jj; ++j) {
@@ -489,7 +491,7 @@ ol.interaction.Modify.prototype.writePolygonGeometry_ = function(feature, geomet
index: i,
segment: segment
});
this.rBush_.insert(ol.extent.boundingExtent(segment), segmentData);
this.rBush_.insert(_ol_extent_.boundingExtent(segment), segmentData);
}
}
};
@@ -500,7 +502,7 @@ ol.interaction.Modify.prototype.writePolygonGeometry_ = function(feature, geomet
* @param {ol.geom.MultiPolygon} geometry Geometry.
* @private
*/
ol.interaction.Modify.prototype.writeMultiPolygonGeometry_ = function(feature, geometry) {
_ol_interaction_Modify_.prototype.writeMultiPolygonGeometry_ = function(feature, geometry) {
var polygons = geometry.getCoordinates();
var coordinates, i, ii, j, jj, k, kk, rings, segment, segmentData;
for (k = 0, kk = polygons.length; k < kk; ++k) {
@@ -516,7 +518,7 @@ ol.interaction.Modify.prototype.writeMultiPolygonGeometry_ = function(feature, g
index: i,
segment: segment
});
this.rBush_.insert(ol.extent.boundingExtent(segment), segmentData);
this.rBush_.insert(_ol_extent_.boundingExtent(segment), segmentData);
}
}
}
@@ -534,23 +536,23 @@ ol.interaction.Modify.prototype.writeMultiPolygonGeometry_ = function(feature, g
* @param {ol.geom.Circle} geometry Geometry.
* @private
*/
ol.interaction.Modify.prototype.writeCircleGeometry_ = function(feature, geometry) {
_ol_interaction_Modify_.prototype.writeCircleGeometry_ = function(feature, geometry) {
var coordinates = geometry.getCenter();
var centerSegmentData = /** @type {ol.ModifySegmentDataType} */ ({
feature: feature,
geometry: geometry,
index: ol.interaction.Modify.MODIFY_SEGMENT_CIRCLE_CENTER_INDEX,
index: _ol_interaction_Modify_.MODIFY_SEGMENT_CIRCLE_CENTER_INDEX,
segment: [coordinates, coordinates]
});
var circumferenceSegmentData = /** @type {ol.ModifySegmentDataType} */ ({
feature: feature,
geometry: geometry,
index: ol.interaction.Modify.MODIFY_SEGMENT_CIRCLE_CIRCUMFERENCE_INDEX,
index: _ol_interaction_Modify_.MODIFY_SEGMENT_CIRCLE_CIRCUMFERENCE_INDEX,
segment: [coordinates, coordinates]
});
var featureSegments = [centerSegmentData, circumferenceSegmentData];
centerSegmentData.featureSegments = circumferenceSegmentData.featureSegments = featureSegments;
this.rBush_.insert(ol.extent.createOrUpdateFromCoordinate(coordinates), centerSegmentData);
this.rBush_.insert(_ol_extent_.createOrUpdateFromCoordinate(coordinates), centerSegmentData);
this.rBush_.insert(geometry.getExtent(), circumferenceSegmentData);
};
@@ -560,7 +562,7 @@ ol.interaction.Modify.prototype.writeCircleGeometry_ = function(feature, geometr
* @param {ol.geom.GeometryCollection} geometry Geometry.
* @private
*/
ol.interaction.Modify.prototype.writeGeometryCollectionGeometry_ = function(feature, geometry) {
_ol_interaction_Modify_.prototype.writeGeometryCollectionGeometry_ = function(feature, geometry) {
var i, geometries = geometry.getGeometriesArray();
for (i = 0; i < geometries.length; ++i) {
this.SEGMENT_WRITERS_[geometries[i].getType()].call(
@@ -574,10 +576,10 @@ ol.interaction.Modify.prototype.writeGeometryCollectionGeometry_ = function(feat
* @return {ol.Feature} Vertex feature.
* @private
*/
ol.interaction.Modify.prototype.createOrUpdateVertexFeature_ = function(coordinates) {
_ol_interaction_Modify_.prototype.createOrUpdateVertexFeature_ = function(coordinates) {
var vertexFeature = this.vertexFeature_;
if (!vertexFeature) {
vertexFeature = new ol.Feature(new ol.geom.Point(coordinates));
vertexFeature = new _ol_Feature_(new _ol_geom_Point_(coordinates));
this.vertexFeature_ = vertexFeature;
this.overlay_.getSource().addFeature(vertexFeature);
} else {
@@ -594,7 +596,7 @@ ol.interaction.Modify.prototype.createOrUpdateVertexFeature_ = function(coordina
* @return {number} The difference in indexes.
* @private
*/
ol.interaction.Modify.compareIndexes_ = function(a, b) {
_ol_interaction_Modify_.compareIndexes_ = function(a, b) {
return a.index - b.index;
};
@@ -605,7 +607,7 @@ ol.interaction.Modify.compareIndexes_ = function(a, b) {
* @this {ol.interaction.Modify}
* @private
*/
ol.interaction.Modify.handleDownEvent_ = function(evt) {
_ol_interaction_Modify_.handleDownEvent_ = function(evt) {
if (!this.condition_(evt)) {
return false;
}
@@ -618,14 +620,14 @@ ol.interaction.Modify.handleDownEvent_ = function(evt) {
var insertVertices = [];
var geometry = /** @type {ol.geom.Point} */ (vertexFeature.getGeometry());
var vertex = geometry.getCoordinates();
var vertexExtent = ol.extent.boundingExtent([vertex]);
var vertexExtent = _ol_extent_.boundingExtent([vertex]);
var segmentDataMatches = this.rBush_.getInExtent(vertexExtent);
var componentSegments = {};
segmentDataMatches.sort(ol.interaction.Modify.compareIndexes_);
segmentDataMatches.sort(_ol_interaction_Modify_.compareIndexes_);
for (var i = 0, ii = segmentDataMatches.length; i < ii; ++i) {
var segmentDataMatch = segmentDataMatches[i];
var segment = segmentDataMatch.segment;
var uid = ol.getUid(segmentDataMatch.feature);
var uid = _ol_.getUid(segmentDataMatch.feature);
var depth = segmentDataMatch.depth;
if (depth) {
uid += '-' + depth.join('-'); // separate feature components
@@ -633,26 +635,26 @@ ol.interaction.Modify.handleDownEvent_ = function(evt) {
if (!componentSegments[uid]) {
componentSegments[uid] = new Array(2);
}
if (segmentDataMatch.geometry.getType() === ol.geom.GeometryType.CIRCLE &&
segmentDataMatch.index === ol.interaction.Modify.MODIFY_SEGMENT_CIRCLE_CIRCUMFERENCE_INDEX) {
if (segmentDataMatch.geometry.getType() === _ol_geom_GeometryType_.CIRCLE &&
segmentDataMatch.index === _ol_interaction_Modify_.MODIFY_SEGMENT_CIRCLE_CIRCUMFERENCE_INDEX) {
var closestVertex = ol.interaction.Modify.closestOnSegmentData_(pixelCoordinate, segmentDataMatch);
if (ol.coordinate.equals(closestVertex, vertex) && !componentSegments[uid][0]) {
var closestVertex = _ol_interaction_Modify_.closestOnSegmentData_(pixelCoordinate, segmentDataMatch);
if (_ol_coordinate_.equals(closestVertex, vertex) && !componentSegments[uid][0]) {
this.dragSegments_.push([segmentDataMatch, 0]);
componentSegments[uid][0] = segmentDataMatch;
}
} else if (ol.coordinate.equals(segment[0], vertex) &&
} else if (_ol_coordinate_.equals(segment[0], vertex) &&
!componentSegments[uid][0]) {
this.dragSegments_.push([segmentDataMatch, 0]);
componentSegments[uid][0] = segmentDataMatch;
} else if (ol.coordinate.equals(segment[1], vertex) &&
} else if (_ol_coordinate_.equals(segment[1], vertex) &&
!componentSegments[uid][1]) {
// prevent dragging closed linestrings by the connecting node
if ((segmentDataMatch.geometry.getType() ===
ol.geom.GeometryType.LINE_STRING ||
_ol_geom_GeometryType_.LINE_STRING ||
segmentDataMatch.geometry.getType() ===
ol.geom.GeometryType.MULTI_LINE_STRING) &&
_ol_geom_GeometryType_.MULTI_LINE_STRING) &&
componentSegments[uid][0] &&
componentSegments[uid][0].index === 0) {
continue;
@@ -660,7 +662,7 @@ ol.interaction.Modify.handleDownEvent_ = function(evt) {
this.dragSegments_.push([segmentDataMatch, 1]);
componentSegments[uid][1] = segmentDataMatch;
} else if (this.insertVertexCondition_(evt) && ol.getUid(segment) in this.vertexSegments_ &&
} else if (this.insertVertexCondition_(evt) && _ol_.getUid(segment) in this.vertexSegments_ &&
(!componentSegments[uid][0] && !componentSegments[uid][1])) {
insertVertices.push([segmentDataMatch, vertex]);
}
@@ -681,7 +683,7 @@ ol.interaction.Modify.handleDownEvent_ = function(evt) {
* @this {ol.interaction.Modify}
* @private
*/
ol.interaction.Modify.handleDragEvent_ = function(evt) {
_ol_interaction_Modify_.handleDragEvent_ = function(evt) {
this.ignoreNextSingleClick_ = false;
this.willModifyFeatures_(evt);
@@ -700,44 +702,44 @@ ol.interaction.Modify.handleDragEvent_ = function(evt) {
}
switch (geometry.getType()) {
case ol.geom.GeometryType.POINT:
case _ol_geom_GeometryType_.POINT:
coordinates = vertex;
segment[0] = segment[1] = vertex;
break;
case ol.geom.GeometryType.MULTI_POINT:
case _ol_geom_GeometryType_.MULTI_POINT:
coordinates = geometry.getCoordinates();
coordinates[segmentData.index] = vertex;
segment[0] = segment[1] = vertex;
break;
case ol.geom.GeometryType.LINE_STRING:
case _ol_geom_GeometryType_.LINE_STRING:
coordinates = geometry.getCoordinates();
coordinates[segmentData.index + index] = vertex;
segment[index] = vertex;
break;
case ol.geom.GeometryType.MULTI_LINE_STRING:
case _ol_geom_GeometryType_.MULTI_LINE_STRING:
coordinates = geometry.getCoordinates();
coordinates[depth[0]][segmentData.index + index] = vertex;
segment[index] = vertex;
break;
case ol.geom.GeometryType.POLYGON:
case _ol_geom_GeometryType_.POLYGON:
coordinates = geometry.getCoordinates();
coordinates[depth[0]][segmentData.index + index] = vertex;
segment[index] = vertex;
break;
case ol.geom.GeometryType.MULTI_POLYGON:
case _ol_geom_GeometryType_.MULTI_POLYGON:
coordinates = geometry.getCoordinates();
coordinates[depth[1]][depth[0]][segmentData.index + index] = vertex;
segment[index] = vertex;
break;
case ol.geom.GeometryType.CIRCLE:
case _ol_geom_GeometryType_.CIRCLE:
segment[0] = segment[1] = vertex;
if (segmentData.index === ol.interaction.Modify.MODIFY_SEGMENT_CIRCLE_CENTER_INDEX) {
if (segmentData.index === _ol_interaction_Modify_.MODIFY_SEGMENT_CIRCLE_CENTER_INDEX) {
this.changingFeature_ = true;
geometry.setCenter(vertex);
this.changingFeature_ = false;
} else { // We're dragging the circle's circumference:
this.changingFeature_ = true;
geometry.setRadius(ol.coordinate.distance(geometry.getCenter(), vertex));
geometry.setRadius(_ol_coordinate_.distance(geometry.getCenter(), vertex));
this.changingFeature_ = false;
}
break;
@@ -759,29 +761,29 @@ ol.interaction.Modify.handleDragEvent_ = function(evt) {
* @this {ol.interaction.Modify}
* @private
*/
ol.interaction.Modify.handleUpEvent_ = function(evt) {
_ol_interaction_Modify_.handleUpEvent_ = function(evt) {
var segmentData;
var geometry;
for (var i = this.dragSegments_.length - 1; i >= 0; --i) {
segmentData = this.dragSegments_[i][0];
geometry = segmentData.geometry;
if (geometry.getType() === ol.geom.GeometryType.CIRCLE) {
if (geometry.getType() === _ol_geom_GeometryType_.CIRCLE) {
// Update a circle object in the R* bush:
var coordinates = geometry.getCenter();
var centerSegmentData = segmentData.featureSegments[0];
var circumferenceSegmentData = segmentData.featureSegments[1];
centerSegmentData.segment[0] = centerSegmentData.segment[1] = coordinates;
circumferenceSegmentData.segment[0] = circumferenceSegmentData.segment[1] = coordinates;
this.rBush_.update(ol.extent.createOrUpdateFromCoordinate(coordinates), centerSegmentData);
this.rBush_.update(_ol_extent_.createOrUpdateFromCoordinate(coordinates), centerSegmentData);
this.rBush_.update(geometry.getExtent(), circumferenceSegmentData);
} else {
this.rBush_.update(ol.extent.boundingExtent(segmentData.segment),
this.rBush_.update(_ol_extent_.boundingExtent(segmentData.segment),
segmentData);
}
}
if (this.modified_) {
this.dispatchEvent(new ol.interaction.Modify.Event(
ol.interaction.ModifyEventType.MODIFYEND, this.features_, evt));
this.dispatchEvent(new _ol_interaction_Modify_.Event(
_ol_interaction_ModifyEventType_.MODIFYEND, this.features_, evt));
this.modified_ = false;
}
return false;
@@ -796,20 +798,20 @@ ol.interaction.Modify.handleUpEvent_ = function(evt) {
* @this {ol.interaction.Modify}
* @api
*/
ol.interaction.Modify.handleEvent = function(mapBrowserEvent) {
if (!(mapBrowserEvent instanceof ol.MapBrowserPointerEvent)) {
_ol_interaction_Modify_.handleEvent = function(mapBrowserEvent) {
if (!(mapBrowserEvent instanceof _ol_MapBrowserPointerEvent_)) {
return true;
}
this.lastPointerEvent_ = mapBrowserEvent;
var handled;
if (!mapBrowserEvent.map.getView().getInteracting() &&
mapBrowserEvent.type == ol.MapBrowserEventType.POINTERMOVE &&
mapBrowserEvent.type == _ol_MapBrowserEventType_.POINTERMOVE &&
!this.handlingDownUpSequence) {
this.handlePointerMove_(mapBrowserEvent);
}
if (this.vertexFeature_ && this.deleteCondition_(mapBrowserEvent)) {
if (mapBrowserEvent.type != ol.MapBrowserEventType.SINGLECLICK ||
if (mapBrowserEvent.type != _ol_MapBrowserEventType_.SINGLECLICK ||
!this.ignoreNextSingleClick_) {
handled = this.removePoint();
} else {
@@ -817,11 +819,11 @@ ol.interaction.Modify.handleEvent = function(mapBrowserEvent) {
}
}
if (mapBrowserEvent.type == ol.MapBrowserEventType.SINGLECLICK) {
if (mapBrowserEvent.type == _ol_MapBrowserEventType_.SINGLECLICK) {
this.ignoreNextSingleClick_ = false;
}
return ol.interaction.Pointer.handleEvent.call(this, mapBrowserEvent) &&
return _ol_interaction_Pointer_.handleEvent.call(this, mapBrowserEvent) &&
!handled;
};
@@ -830,7 +832,7 @@ ol.interaction.Modify.handleEvent = function(mapBrowserEvent) {
* @param {ol.MapBrowserEvent} evt Event.
* @private
*/
ol.interaction.Modify.prototype.handlePointerMove_ = function(evt) {
_ol_interaction_Modify_.prototype.handlePointerMove_ = function(evt) {
this.lastPixel_ = evt.pixel;
this.handlePointerAtPixel_(evt.pixel, evt.map);
};
@@ -841,15 +843,15 @@ ol.interaction.Modify.prototype.handlePointerMove_ = function(evt) {
* @param {ol.PluggableMap} map Map.
* @private
*/
ol.interaction.Modify.prototype.handlePointerAtPixel_ = function(pixel, map) {
_ol_interaction_Modify_.prototype.handlePointerAtPixel_ = function(pixel, map) {
var pixelCoordinate = map.getCoordinateFromPixel(pixel);
var sortByDistance = function(a, b) {
return ol.interaction.Modify.pointDistanceToSegmentDataSquared_(pixelCoordinate, a) -
ol.interaction.Modify.pointDistanceToSegmentDataSquared_(pixelCoordinate, b);
return _ol_interaction_Modify_.pointDistanceToSegmentDataSquared_(pixelCoordinate, a) -
_ol_interaction_Modify_.pointDistanceToSegmentDataSquared_(pixelCoordinate, b);
};
var box = ol.extent.buffer(
ol.extent.createOrUpdateFromCoordinate(pixelCoordinate),
var box = _ol_extent_.buffer(
_ol_extent_.createOrUpdateFromCoordinate(pixelCoordinate),
map.getView().getResolution() * this.pixelTolerance_);
var rBush = this.rBush_;
@@ -858,22 +860,22 @@ ol.interaction.Modify.prototype.handlePointerAtPixel_ = function(pixel, map) {
nodes.sort(sortByDistance);
var node = nodes[0];
var closestSegment = node.segment;
var vertex = ol.interaction.Modify.closestOnSegmentData_(pixelCoordinate, node);
var vertex = _ol_interaction_Modify_.closestOnSegmentData_(pixelCoordinate, node);
var vertexPixel = map.getPixelFromCoordinate(vertex);
var dist = ol.coordinate.distance(pixel, vertexPixel);
var dist = _ol_coordinate_.distance(pixel, vertexPixel);
if (dist <= this.pixelTolerance_) {
var vertexSegments = {};
if (node.geometry.getType() === ol.geom.GeometryType.CIRCLE &&
node.index === ol.interaction.Modify.MODIFY_SEGMENT_CIRCLE_CIRCUMFERENCE_INDEX) {
if (node.geometry.getType() === _ol_geom_GeometryType_.CIRCLE &&
node.index === _ol_interaction_Modify_.MODIFY_SEGMENT_CIRCLE_CIRCUMFERENCE_INDEX) {
this.snappedToVertex_ = true;
this.createOrUpdateVertexFeature_(vertex);
} else {
var pixel1 = map.getPixelFromCoordinate(closestSegment[0]);
var pixel2 = map.getPixelFromCoordinate(closestSegment[1]);
var squaredDist1 = ol.coordinate.squaredDistance(vertexPixel, pixel1);
var squaredDist2 = ol.coordinate.squaredDistance(vertexPixel, pixel2);
var squaredDist1 = _ol_coordinate_.squaredDistance(vertexPixel, pixel1);
var squaredDist2 = _ol_coordinate_.squaredDistance(vertexPixel, pixel2);
dist = Math.sqrt(Math.min(squaredDist1, squaredDist2));
this.snappedToVertex_ = dist <= this.pixelTolerance_;
if (this.snappedToVertex_) {
@@ -884,18 +886,18 @@ ol.interaction.Modify.prototype.handlePointerAtPixel_ = function(pixel, map) {
var segment;
for (var i = 1, ii = nodes.length; i < ii; ++i) {
segment = nodes[i].segment;
if ((ol.coordinate.equals(closestSegment[0], segment[0]) &&
ol.coordinate.equals(closestSegment[1], segment[1]) ||
(ol.coordinate.equals(closestSegment[0], segment[1]) &&
ol.coordinate.equals(closestSegment[1], segment[0])))) {
vertexSegments[ol.getUid(segment)] = true;
if ((_ol_coordinate_.equals(closestSegment[0], segment[0]) &&
_ol_coordinate_.equals(closestSegment[1], segment[1]) ||
(_ol_coordinate_.equals(closestSegment[0], segment[1]) &&
_ol_coordinate_.equals(closestSegment[1], segment[0])))) {
vertexSegments[_ol_.getUid(segment)] = true;
} else {
break;
}
}
}
vertexSegments[ol.getUid(closestSegment)] = true;
vertexSegments[_ol_.getUid(closestSegment)] = true;
this.vertexSegments_ = vertexSegments;
return;
}
@@ -916,21 +918,21 @@ ol.interaction.Modify.prototype.handlePointerAtPixel_ = function(pixel, map) {
* segment we are calculating the distance to.
* @return {number} The square of the distance between a point and a line segment.
*/
ol.interaction.Modify.pointDistanceToSegmentDataSquared_ = function(pointCoordinates, segmentData) {
_ol_interaction_Modify_.pointDistanceToSegmentDataSquared_ = function(pointCoordinates, segmentData) {
var geometry = segmentData.geometry;
if (geometry.getType() === ol.geom.GeometryType.CIRCLE) {
if (geometry.getType() === _ol_geom_GeometryType_.CIRCLE) {
var circleGeometry = /** @type {ol.geom.Circle} */ (geometry);
if (segmentData.index === ol.interaction.Modify.MODIFY_SEGMENT_CIRCLE_CIRCUMFERENCE_INDEX) {
if (segmentData.index === _ol_interaction_Modify_.MODIFY_SEGMENT_CIRCLE_CIRCUMFERENCE_INDEX) {
var distanceToCenterSquared =
ol.coordinate.squaredDistance(circleGeometry.getCenter(), pointCoordinates);
_ol_coordinate_.squaredDistance(circleGeometry.getCenter(), pointCoordinates);
var distanceToCircumference =
Math.sqrt(distanceToCenterSquared) - circleGeometry.getRadius();
return distanceToCircumference * distanceToCircumference;
}
}
return ol.coordinate.squaredDistanceToSegment(pointCoordinates, segmentData.segment);
return _ol_coordinate_.squaredDistanceToSegment(pointCoordinates, segmentData.segment);
};
/**
@@ -942,14 +944,14 @@ ol.interaction.Modify.pointDistanceToSegmentDataSquared_ = function(pointCoordin
* segment which should contain the closest point.
* @return {ol.Coordinate} The point closest to the specified line segment.
*/
ol.interaction.Modify.closestOnSegmentData_ = function(pointCoordinates, segmentData) {
_ol_interaction_Modify_.closestOnSegmentData_ = function(pointCoordinates, segmentData) {
var geometry = segmentData.geometry;
if (geometry.getType() === ol.geom.GeometryType.CIRCLE &&
segmentData.index === ol.interaction.Modify.MODIFY_SEGMENT_CIRCLE_CIRCUMFERENCE_INDEX) {
if (geometry.getType() === _ol_geom_GeometryType_.CIRCLE &&
segmentData.index === _ol_interaction_Modify_.MODIFY_SEGMENT_CIRCLE_CIRCUMFERENCE_INDEX) {
return geometry.getClosestPoint(pointCoordinates);
}
return ol.coordinate.closestOnSegment(pointCoordinates, segmentData.segment);
return _ol_coordinate_.closestOnSegment(pointCoordinates, segmentData.segment);
};
@@ -958,7 +960,7 @@ ol.interaction.Modify.closestOnSegmentData_ = function(pointCoordinates, segment
* @param {ol.Coordinate} vertex Vertex.
* @private
*/
ol.interaction.Modify.prototype.insertVertex_ = function(segmentData, vertex) {
_ol_interaction_Modify_.prototype.insertVertex_ = function(segmentData, vertex) {
var segment = segmentData.segment;
var feature = segmentData.feature;
var geometry = segmentData.geometry;
@@ -971,19 +973,19 @@ ol.interaction.Modify.prototype.insertVertex_ = function(segmentData, vertex) {
}
switch (geometry.getType()) {
case ol.geom.GeometryType.MULTI_LINE_STRING:
case _ol_geom_GeometryType_.MULTI_LINE_STRING:
coordinates = geometry.getCoordinates();
coordinates[depth[0]].splice(index + 1, 0, vertex);
break;
case ol.geom.GeometryType.POLYGON:
case _ol_geom_GeometryType_.POLYGON:
coordinates = geometry.getCoordinates();
coordinates[depth[0]].splice(index + 1, 0, vertex);
break;
case ol.geom.GeometryType.MULTI_POLYGON:
case _ol_geom_GeometryType_.MULTI_POLYGON:
coordinates = geometry.getCoordinates();
coordinates[depth[1]][depth[0]].splice(index + 1, 0, vertex);
break;
case ol.geom.GeometryType.LINE_STRING:
case _ol_geom_GeometryType_.LINE_STRING:
coordinates = geometry.getCoordinates();
coordinates.splice(index + 1, 0, vertex);
break;
@@ -1002,7 +1004,7 @@ ol.interaction.Modify.prototype.insertVertex_ = function(segmentData, vertex) {
depth: depth,
index: index
});
rTree.insert(ol.extent.boundingExtent(newSegmentData.segment),
rTree.insert(_ol_extent_.boundingExtent(newSegmentData.segment),
newSegmentData);
this.dragSegments_.push([newSegmentData, 1]);
@@ -1013,7 +1015,7 @@ ol.interaction.Modify.prototype.insertVertex_ = function(segmentData, vertex) {
depth: depth,
index: index + 1
});
rTree.insert(ol.extent.boundingExtent(newSegmentData2.segment),
rTree.insert(_ol_extent_.boundingExtent(newSegmentData2.segment),
newSegmentData2);
this.dragSegments_.push([newSegmentData2, 0]);
this.ignoreNextSingleClick_ = true;
@@ -1024,13 +1026,13 @@ ol.interaction.Modify.prototype.insertVertex_ = function(segmentData, vertex) {
* @return {boolean} True when a vertex was removed.
* @api
*/
ol.interaction.Modify.prototype.removePoint = function() {
if (this.lastPointerEvent_ && this.lastPointerEvent_.type != ol.MapBrowserEventType.POINTERDRAG) {
_ol_interaction_Modify_.prototype.removePoint = function() {
if (this.lastPointerEvent_ && this.lastPointerEvent_.type != _ol_MapBrowserEventType_.POINTERDRAG) {
var evt = this.lastPointerEvent_;
this.willModifyFeatures_(evt);
this.removeVertex_();
this.dispatchEvent(new ol.interaction.Modify.Event(
ol.interaction.ModifyEventType.MODIFYEND, this.features_, evt));
this.dispatchEvent(new _ol_interaction_Modify_.Event(
_ol_interaction_ModifyEventType_.MODIFYEND, this.features_, evt));
this.modified_ = false;
return true;
}
@@ -1042,7 +1044,7 @@ ol.interaction.Modify.prototype.removePoint = function() {
* @return {boolean} True when a vertex was removed.
* @private
*/
ol.interaction.Modify.prototype.removeVertex_ = function() {
_ol_interaction_Modify_.prototype.removeVertex_ = function() {
var dragSegments = this.dragSegments_;
var segmentsByFeature = {};
var deleted = false;
@@ -1051,7 +1053,7 @@ ol.interaction.Modify.prototype.removeVertex_ = function() {
for (i = dragSegments.length - 1; i >= 0; --i) {
dragSegment = dragSegments[i];
segmentData = dragSegment[0];
uid = ol.getUid(segmentData.feature);
uid = _ol_.getUid(segmentData.feature);
if (segmentData.depth) {
// separate feature components
uid += '-' + segmentData.depth.join('-');
@@ -1086,22 +1088,22 @@ ol.interaction.Modify.prototype.removeVertex_ = function() {
component = coordinates;
deleted = false;
switch (geometry.getType()) {
case ol.geom.GeometryType.MULTI_LINE_STRING:
case _ol_geom_GeometryType_.MULTI_LINE_STRING:
if (coordinates[segmentData.depth[0]].length > 2) {
coordinates[segmentData.depth[0]].splice(index, 1);
deleted = true;
}
break;
case ol.geom.GeometryType.LINE_STRING:
case _ol_geom_GeometryType_.LINE_STRING:
if (coordinates.length > 2) {
coordinates.splice(index, 1);
deleted = true;
}
break;
case ol.geom.GeometryType.MULTI_POLYGON:
case _ol_geom_GeometryType_.MULTI_POLYGON:
component = component[segmentData.depth[1]];
/* falls through */
case ol.geom.GeometryType.POLYGON:
case _ol_geom_GeometryType_.POLYGON:
component = component[segmentData.depth[0]];
if (component.length > 4) {
if (index == component.length - 1) {
@@ -1140,7 +1142,7 @@ ol.interaction.Modify.prototype.removeVertex_ = function() {
index: newIndex,
segment: segments
});
this.rBush_.insert(ol.extent.boundingExtent(newSegmentData.segment),
this.rBush_.insert(_ol_extent_.boundingExtent(newSegmentData.segment),
newSegmentData);
}
this.updateSegmentIndices_(geometry, index, segmentData.depth, -1);
@@ -1161,7 +1163,7 @@ ol.interaction.Modify.prototype.removeVertex_ = function() {
* @param {Array} coordinates Coordinates.
* @private
*/
ol.interaction.Modify.prototype.setGeometryCoordinates_ = function(geometry, coordinates) {
_ol_interaction_Modify_.prototype.setGeometryCoordinates_ = function(geometry, coordinates) {
this.changingFeature_ = true;
geometry.setCoordinates(coordinates);
this.changingFeature_ = false;
@@ -1175,12 +1177,12 @@ ol.interaction.Modify.prototype.setGeometryCoordinates_ = function(geometry, coo
* @param {number} delta Delta (1 or -1).
* @private
*/
ol.interaction.Modify.prototype.updateSegmentIndices_ = function(
_ol_interaction_Modify_.prototype.updateSegmentIndices_ = function(
geometry, index, depth, delta) {
this.rBush_.forEachInExtent(geometry.getExtent(), function(segmentDataMatch) {
if (segmentDataMatch.geometry === geometry &&
(depth === undefined || segmentDataMatch.depth === undefined ||
ol.array.equals(segmentDataMatch.depth, depth)) &&
_ol_array_.equals(segmentDataMatch.depth, depth)) &&
segmentDataMatch.index > index) {
segmentDataMatch.index += delta;
}
@@ -1191,10 +1193,10 @@ ol.interaction.Modify.prototype.updateSegmentIndices_ = function(
/**
* @return {ol.StyleFunction} Styles.
*/
ol.interaction.Modify.getDefaultStyleFunction = function() {
var style = ol.style.Style.createDefaultEditing();
_ol_interaction_Modify_.getDefaultStyleFunction = function() {
var style = _ol_style_Style_.createDefaultEditing();
return function(feature, resolution) {
return style[ol.geom.GeometryType.POINT];
return style[_ol_geom_GeometryType_.POINT];
};
};
@@ -1212,9 +1214,9 @@ ol.interaction.Modify.getDefaultStyleFunction = function() {
* @param {ol.MapBrowserPointerEvent} mapBrowserPointerEvent Associated
* {@link ol.MapBrowserPointerEvent}.
*/
ol.interaction.Modify.Event = function(type, features, mapBrowserPointerEvent) {
_ol_interaction_Modify_.Event = function(type, features, mapBrowserPointerEvent) {
ol.events.Event.call(this, type);
_ol_events_Event_.call(this, type);
/**
* The features being modified.
@@ -1230,4 +1232,5 @@ ol.interaction.Modify.Event = function(type, features, mapBrowserPointerEvent) {
*/
this.mapBrowserEvent = mapBrowserPointerEvent;
};
ol.inherits(ol.interaction.Modify.Event, ol.events.Event);
_ol_.inherits(_ol_interaction_Modify_.Event, _ol_events_Event_);
export default _ol_interaction_Modify_;

View File

@@ -1,10 +1,10 @@
goog.provide('ol.interaction.ModifyEventType');
/**
* @module ol/interaction/ModifyEventType
*/
/**
* @enum {string}
*/
ol.interaction.ModifyEventType = {
var _ol_interaction_ModifyEventType_ = {
/**
* Triggered upon feature modification start
* @event ol.interaction.Modify.Event#modifystart
@@ -18,3 +18,5 @@ ol.interaction.ModifyEventType = {
*/
MODIFYEND: 'modifyend'
};
export default _ol_interaction_ModifyEventType_;

View File

@@ -1,13 +1,13 @@
goog.provide('ol.interaction.MouseWheelZoom');
goog.require('ol');
goog.require('ol.ViewHint');
goog.require('ol.easing');
goog.require('ol.events.EventType');
goog.require('ol.has');
goog.require('ol.interaction.Interaction');
goog.require('ol.math');
/**
* @module ol/interaction/MouseWheelZoom
*/
import _ol_ from '../index.js';
import _ol_ViewHint_ from '../ViewHint.js';
import _ol_easing_ from '../easing.js';
import _ol_events_EventType_ from '../events/EventType.js';
import _ol_has_ from '../has.js';
import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
import _ol_math_ from '../math.js';
/**
* @classdesc
@@ -18,10 +18,10 @@ goog.require('ol.math');
* @param {olx.interaction.MouseWheelZoomOptions=} opt_options Options.
* @api
*/
ol.interaction.MouseWheelZoom = function(opt_options) {
var _ol_interaction_MouseWheelZoom_ = function(opt_options) {
ol.interaction.Interaction.call(this, {
handleEvent: ol.interaction.MouseWheelZoom.handleEvent
_ol_interaction_Interaction_.call(this, {
handleEvent: _ol_interaction_MouseWheelZoom_.handleEvent
});
var options = opt_options || {};
@@ -107,7 +107,8 @@ ol.interaction.MouseWheelZoom = function(opt_options) {
this.trackpadZoomBuffer_ = 1.5;
};
ol.inherits(ol.interaction.MouseWheelZoom, ol.interaction.Interaction);
_ol_.inherits(_ol_interaction_MouseWheelZoom_, _ol_interaction_Interaction_);
/**
@@ -118,9 +119,9 @@ ol.inherits(ol.interaction.MouseWheelZoom, ol.interaction.Interaction);
* @this {ol.interaction.MouseWheelZoom}
* @api
*/
ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
_ol_interaction_MouseWheelZoom_.handleEvent = function(mapBrowserEvent) {
var type = mapBrowserEvent.type;
if (type !== ol.events.EventType.WHEEL && type !== ol.events.EventType.MOUSEWHEEL) {
if (type !== _ol_events_EventType_.WHEEL && type !== _ol_events_EventType_.MOUSEWHEEL) {
return true;
}
@@ -136,18 +137,18 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
// Delta normalisation inspired by
// https://github.com/mapbox/mapbox-gl-js/blob/001c7b9/js/ui/handler/scroll_zoom.js
var delta;
if (mapBrowserEvent.type == ol.events.EventType.WHEEL) {
if (mapBrowserEvent.type == _ol_events_EventType_.WHEEL) {
delta = wheelEvent.deltaY;
if (ol.has.FIREFOX &&
if (_ol_has_.FIREFOX &&
wheelEvent.deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
delta /= ol.has.DEVICE_PIXEL_RATIO;
delta /= _ol_has_.DEVICE_PIXEL_RATIO;
}
if (wheelEvent.deltaMode === WheelEvent.DOM_DELTA_LINE) {
delta *= 40;
}
} else if (mapBrowserEvent.type == ol.events.EventType.MOUSEWHEEL) {
} else if (mapBrowserEvent.type == _ol_events_EventType_.MOUSEWHEEL) {
delta = -wheelEvent.wheelDeltaY;
if (ol.has.SAFARI) {
if (_ol_has_.SAFARI) {
delta /= 3;
}
}
@@ -164,16 +165,16 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
if (!this.mode_ || now - this.startTime_ > this.trackpadEventGap_) {
this.mode_ = Math.abs(delta) < 4 ?
ol.interaction.MouseWheelZoom.Mode_.TRACKPAD :
ol.interaction.MouseWheelZoom.Mode_.WHEEL;
_ol_interaction_MouseWheelZoom_.Mode_.TRACKPAD :
_ol_interaction_MouseWheelZoom_.Mode_.WHEEL;
}
if (this.mode_ === ol.interaction.MouseWheelZoom.Mode_.TRACKPAD) {
if (this.mode_ === _ol_interaction_MouseWheelZoom_.Mode_.TRACKPAD) {
var view = map.getView();
if (this.trackpadTimeoutId_) {
clearTimeout(this.trackpadTimeoutId_);
} else {
view.setHint(ol.ViewHint.INTERACTING, 1);
view.setHint(_ol_ViewHint_.INTERACTING, 1);
}
this.trackpadTimeoutId_ = setTimeout(this.decrementInteractingHint_.bind(this), this.trackpadEventGap_);
var resolution = view.getResolution() * Math.pow(2, delta / this.trackpadDeltaPerZoom_);
@@ -196,7 +197,7 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
if (rebound === 0 && this.constrainResolution_) {
view.animate({
resolution: view.constrainResolution(resolution, delta > 0 ? -1 : 1),
easing: ol.easing.easeOut,
easing: _ol_easing_.easeOut,
anchor: this.lastAnchor_,
duration: this.duration_
});
@@ -205,14 +206,14 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
if (rebound > 0) {
view.animate({
resolution: minResolution,
easing: ol.easing.easeOut,
easing: _ol_easing_.easeOut,
anchor: this.lastAnchor_,
duration: 500
});
} else if (rebound < 0) {
view.animate({
resolution: maxResolution,
easing: ol.easing.easeOut,
easing: _ol_easing_.easeOut,
anchor: this.lastAnchor_,
duration: 500
});
@@ -235,10 +236,10 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
/**
* @private
*/
ol.interaction.MouseWheelZoom.prototype.decrementInteractingHint_ = function() {
_ol_interaction_MouseWheelZoom_.prototype.decrementInteractingHint_ = function() {
this.trackpadTimeoutId_ = undefined;
var view = this.getMap().getView();
view.setHint(ol.ViewHint.INTERACTING, -1);
view.setHint(_ol_ViewHint_.INTERACTING, -1);
};
@@ -246,14 +247,14 @@ ol.interaction.MouseWheelZoom.prototype.decrementInteractingHint_ = function() {
* @private
* @param {ol.PluggableMap} map Map.
*/
ol.interaction.MouseWheelZoom.prototype.handleWheelZoom_ = function(map) {
_ol_interaction_MouseWheelZoom_.prototype.handleWheelZoom_ = function(map) {
var view = map.getView();
if (view.getAnimating()) {
view.cancelAnimations();
}
var maxDelta = ol.MOUSEWHEELZOOM_MAXDELTA;
var delta = ol.math.clamp(this.delta_, -maxDelta, maxDelta);
ol.interaction.Interaction.zoomByDelta(view, -delta, this.lastAnchor_,
var maxDelta = _ol_.MOUSEWHEELZOOM_MAXDELTA;
var delta = _ol_math_.clamp(this.delta_, -maxDelta, maxDelta);
_ol_interaction_Interaction_.zoomByDelta(view, -delta, this.lastAnchor_,
this.duration_);
this.mode_ = undefined;
this.delta_ = 0;
@@ -269,7 +270,7 @@ ol.interaction.MouseWheelZoom.prototype.handleWheelZoom_ = function(map) {
* to zoom to the center of the map
* @api
*/
ol.interaction.MouseWheelZoom.prototype.setMouseAnchor = function(useAnchor) {
_ol_interaction_MouseWheelZoom_.prototype.setMouseAnchor = function(useAnchor) {
this.useAnchor_ = useAnchor;
if (!useAnchor) {
this.lastAnchor_ = null;
@@ -281,7 +282,8 @@ ol.interaction.MouseWheelZoom.prototype.setMouseAnchor = function(useAnchor) {
* @enum {string}
* @private
*/
ol.interaction.MouseWheelZoom.Mode_ = {
_ol_interaction_MouseWheelZoom_.Mode_ = {
TRACKPAD: 'trackpad',
WHEEL: 'wheel'
};
export default _ol_interaction_MouseWheelZoom_;

View File

@@ -1,12 +1,12 @@
goog.provide('ol.interaction.PinchRotate');
goog.require('ol');
goog.require('ol.ViewHint');
goog.require('ol.functions');
goog.require('ol.interaction.Interaction');
goog.require('ol.interaction.Pointer');
goog.require('ol.RotationConstraint');
/**
* @module ol/interaction/PinchRotate
*/
import _ol_ from '../index.js';
import _ol_ViewHint_ from '../ViewHint.js';
import _ol_functions_ from '../functions.js';
import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
import _ol_interaction_Pointer_ from '../interaction/Pointer.js';
import _ol_RotationConstraint_ from '../RotationConstraint.js';
/**
* @classdesc
@@ -18,12 +18,12 @@ goog.require('ol.RotationConstraint');
* @param {olx.interaction.PinchRotateOptions=} opt_options Options.
* @api
*/
ol.interaction.PinchRotate = function(opt_options) {
var _ol_interaction_PinchRotate_ = function(opt_options) {
ol.interaction.Pointer.call(this, {
handleDownEvent: ol.interaction.PinchRotate.handleDownEvent_,
handleDragEvent: ol.interaction.PinchRotate.handleDragEvent_,
handleUpEvent: ol.interaction.PinchRotate.handleUpEvent_
_ol_interaction_Pointer_.call(this, {
handleDownEvent: _ol_interaction_PinchRotate_.handleDownEvent_,
handleDragEvent: _ol_interaction_PinchRotate_.handleDragEvent_,
handleUpEvent: _ol_interaction_PinchRotate_.handleUpEvent_
});
var options = opt_options || {};
@@ -65,7 +65,8 @@ ol.interaction.PinchRotate = function(opt_options) {
this.duration_ = options.duration !== undefined ? options.duration : 250;
};
ol.inherits(ol.interaction.PinchRotate, ol.interaction.Pointer);
_ol_.inherits(_ol_interaction_PinchRotate_, _ol_interaction_Pointer_);
/**
@@ -73,7 +74,7 @@ ol.inherits(ol.interaction.PinchRotate, ol.interaction.Pointer);
* @this {ol.interaction.PinchRotate}
* @private
*/
ol.interaction.PinchRotate.handleDragEvent_ = function(mapBrowserEvent) {
_ol_interaction_PinchRotate_.handleDragEvent_ = function(mapBrowserEvent) {
var rotationDelta = 0.0;
var touch0 = this.targetPointers[0];
@@ -97,7 +98,7 @@ ol.interaction.PinchRotate.handleDragEvent_ = function(mapBrowserEvent) {
var map = mapBrowserEvent.map;
var view = map.getView();
if (view.getConstraints().rotation === ol.RotationConstraint.disable) {
if (view.getConstraints().rotation === _ol_RotationConstraint_.disable) {
return;
}
@@ -105,7 +106,7 @@ ol.interaction.PinchRotate.handleDragEvent_ = function(mapBrowserEvent) {
// FIXME: should be the intersection point between the lines:
// touch0,touch1 and previousTouch0,previousTouch1
var viewportPosition = map.getViewport().getBoundingClientRect();
var centroid = ol.interaction.Pointer.centroid(this.targetPointers);
var centroid = _ol_interaction_Pointer_.centroid(this.targetPointers);
centroid[0] -= viewportPosition.left;
centroid[1] -= viewportPosition.top;
this.anchor_ = map.getCoordinateFromPixel(centroid);
@@ -114,7 +115,7 @@ ol.interaction.PinchRotate.handleDragEvent_ = function(mapBrowserEvent) {
if (this.rotating_) {
var rotation = view.getRotation();
map.render();
ol.interaction.Interaction.rotateWithoutConstraints(view,
_ol_interaction_Interaction_.rotateWithoutConstraints(view,
rotation + rotationDelta, this.anchor_);
}
};
@@ -126,14 +127,14 @@ ol.interaction.PinchRotate.handleDragEvent_ = function(mapBrowserEvent) {
* @this {ol.interaction.PinchRotate}
* @private
*/
ol.interaction.PinchRotate.handleUpEvent_ = function(mapBrowserEvent) {
_ol_interaction_PinchRotate_.handleUpEvent_ = function(mapBrowserEvent) {
if (this.targetPointers.length < 2) {
var map = mapBrowserEvent.map;
var view = map.getView();
view.setHint(ol.ViewHint.INTERACTING, -1);
view.setHint(_ol_ViewHint_.INTERACTING, -1);
if (this.rotating_) {
var rotation = view.getRotation();
ol.interaction.Interaction.rotate(
_ol_interaction_Interaction_.rotate(
view, rotation, this.anchor_, this.duration_);
}
return false;
@@ -149,7 +150,7 @@ ol.interaction.PinchRotate.handleUpEvent_ = function(mapBrowserEvent) {
* @this {ol.interaction.PinchRotate}
* @private
*/
ol.interaction.PinchRotate.handleDownEvent_ = function(mapBrowserEvent) {
_ol_interaction_PinchRotate_.handleDownEvent_ = function(mapBrowserEvent) {
if (this.targetPointers.length >= 2) {
var map = mapBrowserEvent.map;
this.anchor_ = null;
@@ -157,7 +158,7 @@ ol.interaction.PinchRotate.handleDownEvent_ = function(mapBrowserEvent) {
this.rotating_ = false;
this.rotationDelta_ = 0.0;
if (!this.handlingDownUpSequence) {
map.getView().setHint(ol.ViewHint.INTERACTING, 1);
map.getView().setHint(_ol_ViewHint_.INTERACTING, 1);
}
return true;
} else {
@@ -169,4 +170,5 @@ ol.interaction.PinchRotate.handleDownEvent_ = function(mapBrowserEvent) {
/**
* @inheritDoc
*/
ol.interaction.PinchRotate.prototype.shouldStopEvent = ol.functions.FALSE;
_ol_interaction_PinchRotate_.prototype.shouldStopEvent = _ol_functions_.FALSE;
export default _ol_interaction_PinchRotate_;

View File

@@ -1,11 +1,11 @@
goog.provide('ol.interaction.PinchZoom');
goog.require('ol');
goog.require('ol.ViewHint');
goog.require('ol.functions');
goog.require('ol.interaction.Interaction');
goog.require('ol.interaction.Pointer');
/**
* @module ol/interaction/PinchZoom
*/
import _ol_ from '../index.js';
import _ol_ViewHint_ from '../ViewHint.js';
import _ol_functions_ from '../functions.js';
import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
import _ol_interaction_Pointer_ from '../interaction/Pointer.js';
/**
* @classdesc
@@ -17,12 +17,12 @@ goog.require('ol.interaction.Pointer');
* @param {olx.interaction.PinchZoomOptions=} opt_options Options.
* @api
*/
ol.interaction.PinchZoom = function(opt_options) {
var _ol_interaction_PinchZoom_ = function(opt_options) {
ol.interaction.Pointer.call(this, {
handleDownEvent: ol.interaction.PinchZoom.handleDownEvent_,
handleDragEvent: ol.interaction.PinchZoom.handleDragEvent_,
handleUpEvent: ol.interaction.PinchZoom.handleUpEvent_
_ol_interaction_Pointer_.call(this, {
handleDownEvent: _ol_interaction_PinchZoom_.handleDownEvent_,
handleDragEvent: _ol_interaction_PinchZoom_.handleDragEvent_,
handleUpEvent: _ol_interaction_PinchZoom_.handleUpEvent_
});
var options = opt_options ? opt_options : {};
@@ -58,7 +58,8 @@ ol.interaction.PinchZoom = function(opt_options) {
this.lastScaleDelta_ = 1;
};
ol.inherits(ol.interaction.PinchZoom, ol.interaction.Pointer);
_ol_.inherits(_ol_interaction_PinchZoom_, _ol_interaction_Pointer_);
/**
@@ -66,7 +67,7 @@ ol.inherits(ol.interaction.PinchZoom, ol.interaction.Pointer);
* @this {ol.interaction.PinchZoom}
* @private
*/
ol.interaction.PinchZoom.handleDragEvent_ = function(mapBrowserEvent) {
_ol_interaction_PinchZoom_.handleDragEvent_ = function(mapBrowserEvent) {
var scaleDelta = 1.0;
var touch0 = this.targetPointers[0];
@@ -103,14 +104,14 @@ ol.interaction.PinchZoom.handleDragEvent_ = function(mapBrowserEvent) {
// scale anchor point.
var viewportPosition = map.getViewport().getBoundingClientRect();
var centroid = ol.interaction.Pointer.centroid(this.targetPointers);
var centroid = _ol_interaction_Pointer_.centroid(this.targetPointers);
centroid[0] -= viewportPosition.left;
centroid[1] -= viewportPosition.top;
this.anchor_ = map.getCoordinateFromPixel(centroid);
// scale, bypass the resolution constraint
map.render();
ol.interaction.Interaction.zoomWithoutConstraints(view, newResolution, this.anchor_);
_ol_interaction_Interaction_.zoomWithoutConstraints(view, newResolution, this.anchor_);
};
@@ -120,11 +121,11 @@ ol.interaction.PinchZoom.handleDragEvent_ = function(mapBrowserEvent) {
* @this {ol.interaction.PinchZoom}
* @private
*/
ol.interaction.PinchZoom.handleUpEvent_ = function(mapBrowserEvent) {
_ol_interaction_PinchZoom_.handleUpEvent_ = function(mapBrowserEvent) {
if (this.targetPointers.length < 2) {
var map = mapBrowserEvent.map;
var view = map.getView();
view.setHint(ol.ViewHint.INTERACTING, -1);
view.setHint(_ol_ViewHint_.INTERACTING, -1);
var resolution = view.getResolution();
if (this.constrainResolution_ ||
resolution < view.getMinResolution() ||
@@ -133,7 +134,7 @@ ol.interaction.PinchZoom.handleUpEvent_ = function(mapBrowserEvent) {
// direction not to zoom out/in if user was pinching in/out.
// Direction is > 0 if pinching out, and < 0 if pinching in.
var direction = this.lastScaleDelta_ - 1;
ol.interaction.Interaction.zoom(view, resolution,
_ol_interaction_Interaction_.zoom(view, resolution,
this.anchor_, this.duration_, direction);
}
return false;
@@ -149,14 +150,14 @@ ol.interaction.PinchZoom.handleUpEvent_ = function(mapBrowserEvent) {
* @this {ol.interaction.PinchZoom}
* @private
*/
ol.interaction.PinchZoom.handleDownEvent_ = function(mapBrowserEvent) {
_ol_interaction_PinchZoom_.handleDownEvent_ = function(mapBrowserEvent) {
if (this.targetPointers.length >= 2) {
var map = mapBrowserEvent.map;
this.anchor_ = null;
this.lastDistance_ = undefined;
this.lastScaleDelta_ = 1;
if (!this.handlingDownUpSequence) {
map.getView().setHint(ol.ViewHint.INTERACTING, 1);
map.getView().setHint(_ol_ViewHint_.INTERACTING, 1);
}
return true;
} else {
@@ -168,4 +169,5 @@ ol.interaction.PinchZoom.handleDownEvent_ = function(mapBrowserEvent) {
/**
* @inheritDoc
*/
ol.interaction.PinchZoom.prototype.shouldStopEvent = ol.functions.FALSE;
_ol_interaction_PinchZoom_.prototype.shouldStopEvent = _ol_functions_.FALSE;
export default _ol_interaction_PinchZoom_;

View File

@@ -1,12 +1,12 @@
goog.provide('ol.interaction.Pointer');
goog.require('ol');
goog.require('ol.functions');
goog.require('ol.MapBrowserEventType');
goog.require('ol.MapBrowserPointerEvent');
goog.require('ol.interaction.Interaction');
goog.require('ol.obj');
/**
* @module ol/interaction/Pointer
*/
import _ol_ from '../index.js';
import _ol_functions_ from '../functions.js';
import _ol_MapBrowserEventType_ from '../MapBrowserEventType.js';
import _ol_MapBrowserPointerEvent_ from '../MapBrowserPointerEvent.js';
import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
import _ol_obj_ from '../obj.js';
/**
* @classdesc
@@ -23,14 +23,14 @@ goog.require('ol.obj');
* @extends {ol.interaction.Interaction}
* @api
*/
ol.interaction.Pointer = function(opt_options) {
var _ol_interaction_Pointer_ = function(opt_options) {
var options = opt_options ? opt_options : {};
var handleEvent = options.handleEvent ?
options.handleEvent : ol.interaction.Pointer.handleEvent;
options.handleEvent : _ol_interaction_Pointer_.handleEvent;
ol.interaction.Interaction.call(this, {
_ol_interaction_Interaction_.call(this, {
handleEvent: handleEvent
});
@@ -39,28 +39,28 @@ ol.interaction.Pointer = function(opt_options) {
* @private
*/
this.handleDownEvent_ = options.handleDownEvent ?
options.handleDownEvent : ol.interaction.Pointer.handleDownEvent;
options.handleDownEvent : _ol_interaction_Pointer_.handleDownEvent;
/**
* @type {function(ol.MapBrowserPointerEvent)}
* @private
*/
this.handleDragEvent_ = options.handleDragEvent ?
options.handleDragEvent : ol.interaction.Pointer.handleDragEvent;
options.handleDragEvent : _ol_interaction_Pointer_.handleDragEvent;
/**
* @type {function(ol.MapBrowserPointerEvent)}
* @private
*/
this.handleMoveEvent_ = options.handleMoveEvent ?
options.handleMoveEvent : ol.interaction.Pointer.handleMoveEvent;
options.handleMoveEvent : _ol_interaction_Pointer_.handleMoveEvent;
/**
* @type {function(ol.MapBrowserPointerEvent):boolean}
* @private
*/
this.handleUpEvent_ = options.handleUpEvent ?
options.handleUpEvent : ol.interaction.Pointer.handleUpEvent;
options.handleUpEvent : _ol_interaction_Pointer_.handleUpEvent;
/**
* @type {boolean}
@@ -81,14 +81,15 @@ ol.interaction.Pointer = function(opt_options) {
this.targetPointers = [];
};
ol.inherits(ol.interaction.Pointer, ol.interaction.Interaction);
_ol_.inherits(_ol_interaction_Pointer_, _ol_interaction_Interaction_);
/**
* @param {Array.<ol.pointer.PointerEvent>} pointerEvents List of events.
* @return {ol.Pixel} Centroid pixel.
*/
ol.interaction.Pointer.centroid = function(pointerEvents) {
_ol_interaction_Pointer_.centroid = function(pointerEvents) {
var length = pointerEvents.length;
var clientX = 0;
var clientY = 0;
@@ -106,12 +107,11 @@ ol.interaction.Pointer.centroid = function(pointerEvents) {
* or pointerup event.
* @private
*/
ol.interaction.Pointer.prototype.isPointerDraggingEvent_ = function(mapBrowserEvent) {
_ol_interaction_Pointer_.prototype.isPointerDraggingEvent_ = function(mapBrowserEvent) {
var type = mapBrowserEvent.type;
return (
type === ol.MapBrowserEventType.POINTERDOWN ||
type === ol.MapBrowserEventType.POINTERDRAG ||
type === ol.MapBrowserEventType.POINTERUP);
return type === _ol_MapBrowserEventType_.POINTERDOWN ||
type === _ol_MapBrowserEventType_.POINTERDRAG ||
type === _ol_MapBrowserEventType_.POINTERUP;
};
@@ -119,21 +119,21 @@ ol.interaction.Pointer.prototype.isPointerDraggingEvent_ = function(mapBrowserEv
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
* @private
*/
ol.interaction.Pointer.prototype.updateTrackedPointers_ = function(mapBrowserEvent) {
_ol_interaction_Pointer_.prototype.updateTrackedPointers_ = function(mapBrowserEvent) {
if (this.isPointerDraggingEvent_(mapBrowserEvent)) {
var event = mapBrowserEvent.pointerEvent;
var id = event.pointerId.toString();
if (mapBrowserEvent.type == ol.MapBrowserEventType.POINTERUP) {
if (mapBrowserEvent.type == _ol_MapBrowserEventType_.POINTERUP) {
delete this.trackedPointers_[id];
} else if (mapBrowserEvent.type ==
ol.MapBrowserEventType.POINTERDOWN) {
_ol_MapBrowserEventType_.POINTERDOWN) {
this.trackedPointers_[id] = event;
} else if (id in this.trackedPointers_) {
// update only when there was a pointerdown event for this pointer
this.trackedPointers_[id] = event;
}
this.targetPointers = ol.obj.getValues(this.trackedPointers_);
this.targetPointers = _ol_obj_.getValues(this.trackedPointers_);
}
};
@@ -142,7 +142,7 @@ ol.interaction.Pointer.prototype.updateTrackedPointers_ = function(mapBrowserEve
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
* @this {ol.interaction.Pointer}
*/
ol.interaction.Pointer.handleDragEvent = ol.nullFunction;
_ol_interaction_Pointer_.handleDragEvent = _ol_.nullFunction;
/**
@@ -150,7 +150,7 @@ ol.interaction.Pointer.handleDragEvent = ol.nullFunction;
* @return {boolean} Capture dragging.
* @this {ol.interaction.Pointer}
*/
ol.interaction.Pointer.handleUpEvent = ol.functions.FALSE;
_ol_interaction_Pointer_.handleUpEvent = _ol_functions_.FALSE;
/**
@@ -158,14 +158,14 @@ ol.interaction.Pointer.handleUpEvent = ol.functions.FALSE;
* @return {boolean} Capture dragging.
* @this {ol.interaction.Pointer}
*/
ol.interaction.Pointer.handleDownEvent = ol.functions.FALSE;
_ol_interaction_Pointer_.handleDownEvent = _ol_functions_.FALSE;
/**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
* @this {ol.interaction.Pointer}
*/
ol.interaction.Pointer.handleMoveEvent = ol.nullFunction;
_ol_interaction_Pointer_.handleMoveEvent = _ol_.nullFunction;
/**
@@ -177,26 +177,26 @@ ol.interaction.Pointer.handleMoveEvent = ol.nullFunction;
* @this {ol.interaction.Pointer}
* @api
*/
ol.interaction.Pointer.handleEvent = function(mapBrowserEvent) {
if (!(mapBrowserEvent instanceof ol.MapBrowserPointerEvent)) {
_ol_interaction_Pointer_.handleEvent = function(mapBrowserEvent) {
if (!(mapBrowserEvent instanceof _ol_MapBrowserPointerEvent_)) {
return true;
}
var stopEvent = false;
this.updateTrackedPointers_(mapBrowserEvent);
if (this.handlingDownUpSequence) {
if (mapBrowserEvent.type == ol.MapBrowserEventType.POINTERDRAG) {
if (mapBrowserEvent.type == _ol_MapBrowserEventType_.POINTERDRAG) {
this.handleDragEvent_(mapBrowserEvent);
} else if (mapBrowserEvent.type == ol.MapBrowserEventType.POINTERUP) {
} else if (mapBrowserEvent.type == _ol_MapBrowserEventType_.POINTERUP) {
var handledUp = this.handleUpEvent_(mapBrowserEvent);
this.handlingDownUpSequence = handledUp && this.targetPointers.length > 0;
}
} else {
if (mapBrowserEvent.type == ol.MapBrowserEventType.POINTERDOWN) {
if (mapBrowserEvent.type == _ol_MapBrowserEventType_.POINTERDOWN) {
var handled = this.handleDownEvent_(mapBrowserEvent);
this.handlingDownUpSequence = handled;
stopEvent = this.shouldStopEvent(handled);
} else if (mapBrowserEvent.type == ol.MapBrowserEventType.POINTERMOVE) {
} else if (mapBrowserEvent.type == _ol_MapBrowserEventType_.POINTERMOVE) {
this.handleMoveEvent_(mapBrowserEvent);
}
}
@@ -217,6 +217,7 @@ ol.interaction.Pointer.handleEvent = function(mapBrowserEvent) {
* @return {boolean} Should the event be stopped?
* @protected
*/
ol.interaction.Pointer.prototype.shouldStopEvent = function(handled) {
_ol_interaction_Pointer_.prototype.shouldStopEvent = function(handled) {
return handled;
};
export default _ol_interaction_Pointer_;

View File

@@ -1,8 +1,11 @@
goog.provide('ol.interaction.Property');
/**
* @module ol/interaction/Property
*/
/**
* @enum {string}
*/
ol.interaction.Property = {
var _ol_interaction_Property_ = {
ACTIVE: 'active'
};
export default _ol_interaction_Property_;

View File

@@ -1,19 +1,19 @@
goog.provide('ol.interaction.Select');
goog.require('ol');
goog.require('ol.CollectionEventType');
goog.require('ol.array');
goog.require('ol.events');
goog.require('ol.events.Event');
goog.require('ol.events.condition');
goog.require('ol.functions');
goog.require('ol.geom.GeometryType');
goog.require('ol.interaction.Interaction');
goog.require('ol.layer.Vector');
goog.require('ol.obj');
goog.require('ol.source.Vector');
goog.require('ol.style.Style');
/**
* @module ol/interaction/Select
*/
import _ol_ from '../index.js';
import _ol_CollectionEventType_ from '../CollectionEventType.js';
import _ol_array_ from '../array.js';
import _ol_events_ from '../events.js';
import _ol_events_Event_ from '../events/Event.js';
import _ol_events_condition_ from '../events/condition.js';
import _ol_functions_ from '../functions.js';
import _ol_geom_GeometryType_ from '../geom/GeometryType.js';
import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
import _ol_layer_Vector_ from '../layer/Vector.js';
import _ol_obj_ from '../obj.js';
import _ol_source_Vector_ from '../source/Vector.js';
import _ol_style_Style_ from '../style/Style.js';
/**
* @classdesc
@@ -33,10 +33,10 @@ goog.require('ol.style.Style');
* @fires ol.interaction.Select.Event
* @api
*/
ol.interaction.Select = function(opt_options) {
var _ol_interaction_Select_ = function(opt_options) {
ol.interaction.Interaction.call(this, {
handleEvent: ol.interaction.Select.handleEvent
_ol_interaction_Interaction_.call(this, {
handleEvent: _ol_interaction_Select_.handleEvent
});
var options = opt_options ? opt_options : {};
@@ -46,28 +46,28 @@ ol.interaction.Select = function(opt_options) {
* @type {ol.EventsConditionType}
*/
this.condition_ = options.condition ?
options.condition : ol.events.condition.singleClick;
options.condition : _ol_events_condition_.singleClick;
/**
* @private
* @type {ol.EventsConditionType}
*/
this.addCondition_ = options.addCondition ?
options.addCondition : ol.events.condition.never;
options.addCondition : _ol_events_condition_.never;
/**
* @private
* @type {ol.EventsConditionType}
*/
this.removeCondition_ = options.removeCondition ?
options.removeCondition : ol.events.condition.never;
options.removeCondition : _ol_events_condition_.never;
/**
* @private
* @type {ol.EventsConditionType}
*/
this.toggleCondition_ = options.toggleCondition ?
options.toggleCondition : ol.events.condition.shiftKeyOnly;
options.toggleCondition : _ol_events_condition_.shiftKeyOnly;
/**
* @private
@@ -80,7 +80,7 @@ ol.interaction.Select = function(opt_options) {
* @type {ol.SelectFilterFunction}
*/
this.filter_ = options.filter ? options.filter :
ol.functions.TRUE;
_ol_functions_.TRUE;
/**
* @private
@@ -88,14 +88,14 @@ ol.interaction.Select = function(opt_options) {
*/
this.hitTolerance_ = options.hitTolerance ? options.hitTolerance : 0;
var featureOverlay = new ol.layer.Vector({
source: new ol.source.Vector({
var featureOverlay = new _ol_layer_Vector_({
source: new _ol_source_Vector_({
useSpatialIndex: false,
features: options.features,
wrapX: options.wrapX
}),
style: options.style ? options.style :
ol.interaction.Select.getDefaultStyleFunction(),
_ol_interaction_Select_.getDefaultStyleFunction(),
updateWhileAnimating: true,
updateWhileInteracting: true
});
@@ -114,11 +114,11 @@ ol.interaction.Select = function(opt_options) {
} else {
var layers = options.layers;
layerFilter = function(layer) {
return ol.array.includes(layers, layer);
return _ol_array_.includes(layers, layer);
};
}
} else {
layerFilter = ol.functions.TRUE;
layerFilter = _ol_functions_.TRUE;
}
/**
@@ -136,13 +136,14 @@ ol.interaction.Select = function(opt_options) {
this.featureLayerAssociation_ = {};
var features = this.featureOverlay_.getSource().getFeaturesCollection();
ol.events.listen(features, ol.CollectionEventType.ADD,
_ol_events_.listen(features, _ol_CollectionEventType_.ADD,
this.addFeature_, this);
ol.events.listen(features, ol.CollectionEventType.REMOVE,
_ol_events_.listen(features, _ol_CollectionEventType_.REMOVE,
this.removeFeature_, this);
};
ol.inherits(ol.interaction.Select, ol.interaction.Interaction);
_ol_.inherits(_ol_interaction_Select_, _ol_interaction_Interaction_);
/**
@@ -150,8 +151,8 @@ ol.inherits(ol.interaction.Select, ol.interaction.Interaction);
* @param {ol.layer.Layer} layer Layer.
* @private
*/
ol.interaction.Select.prototype.addFeatureLayerAssociation_ = function(feature, layer) {
var key = ol.getUid(feature);
_ol_interaction_Select_.prototype.addFeatureLayerAssociation_ = function(feature, layer) {
var key = _ol_.getUid(feature);
this.featureLayerAssociation_[key] = layer;
};
@@ -161,7 +162,7 @@ ol.interaction.Select.prototype.addFeatureLayerAssociation_ = function(feature,
* @return {ol.Collection.<ol.Feature>} Features collection.
* @api
*/
ol.interaction.Select.prototype.getFeatures = function() {
_ol_interaction_Select_.prototype.getFeatures = function() {
return this.featureOverlay_.getSource().getFeaturesCollection();
};
@@ -171,7 +172,7 @@ ol.interaction.Select.prototype.getFeatures = function() {
* @returns {number} Hit tolerance in pixels.
* @api
*/
ol.interaction.Select.prototype.getHitTolerance = function() {
_ol_interaction_Select_.prototype.getHitTolerance = function() {
return this.hitTolerance_;
};
@@ -185,8 +186,8 @@ ol.interaction.Select.prototype.getHitTolerance = function() {
* @return {ol.layer.Vector} Layer.
* @api
*/
ol.interaction.Select.prototype.getLayer = function(feature) {
var key = ol.getUid(feature);
_ol_interaction_Select_.prototype.getLayer = function(feature) {
var key = _ol_.getUid(feature);
return /** @type {ol.layer.Vector} */ (this.featureLayerAssociation_[key]);
};
@@ -199,7 +200,7 @@ ol.interaction.Select.prototype.getLayer = function(feature) {
* @this {ol.interaction.Select}
* @api
*/
ol.interaction.Select.handleEvent = function(mapBrowserEvent) {
_ol_interaction_Select_.handleEvent = function(mapBrowserEvent) {
if (!this.condition_(mapBrowserEvent)) {
return true;
}
@@ -215,7 +216,7 @@ ol.interaction.Select.handleEvent = function(mapBrowserEvent) {
// Replace the currently selected feature(s) with the feature(s) at the
// pixel, or clear the selected feature(s) if there is no feature at
// the pixel.
ol.obj.clear(this.featureLayerAssociation_);
_ol_obj_.clear(this.featureLayerAssociation_);
map.forEachFeatureAtPixel(mapBrowserEvent.pixel,
(
/**
@@ -260,11 +261,11 @@ ol.interaction.Select.handleEvent = function(mapBrowserEvent) {
function(feature, layer) {
if (this.filter_(feature, layer)) {
if ((add || toggle) &&
!ol.array.includes(features.getArray(), feature)) {
!_ol_array_.includes(features.getArray(), feature)) {
selected.push(feature);
this.addFeatureLayerAssociation_(feature, layer);
} else if ((remove || toggle) &&
ol.array.includes(features.getArray(), feature)) {
_ol_array_.includes(features.getArray(), feature)) {
deselected.push(feature);
this.removeFeatureLayerAssociation_(feature);
}
@@ -282,10 +283,10 @@ ol.interaction.Select.handleEvent = function(mapBrowserEvent) {
}
if (selected.length > 0 || deselected.length > 0) {
this.dispatchEvent(
new ol.interaction.Select.Event(ol.interaction.Select.EventType_.SELECT,
new _ol_interaction_Select_.Event(_ol_interaction_Select_.EventType_.SELECT,
selected, deselected, mapBrowserEvent));
}
return ol.events.condition.pointerMove(mapBrowserEvent);
return _ol_events_condition_.pointerMove(mapBrowserEvent);
};
@@ -296,7 +297,7 @@ ol.interaction.Select.handleEvent = function(mapBrowserEvent) {
* @param {number} hitTolerance Hit tolerance in pixels.
* @api
*/
ol.interaction.Select.prototype.setHitTolerance = function(hitTolerance) {
_ol_interaction_Select_.prototype.setHitTolerance = function(hitTolerance) {
this.hitTolerance_ = hitTolerance;
};
@@ -308,14 +309,14 @@ ol.interaction.Select.prototype.setHitTolerance = function(hitTolerance) {
* @override
* @api
*/
ol.interaction.Select.prototype.setMap = function(map) {
_ol_interaction_Select_.prototype.setMap = function(map) {
var currentMap = this.getMap();
var selectedFeatures =
this.featureOverlay_.getSource().getFeaturesCollection();
if (currentMap) {
selectedFeatures.forEach(currentMap.unskipFeature, currentMap);
}
ol.interaction.Interaction.prototype.setMap.call(this, map);
_ol_interaction_Interaction_.prototype.setMap.call(this, map);
this.featureOverlay_.setMap(map);
if (map) {
selectedFeatures.forEach(map.skipFeature, map);
@@ -326,12 +327,12 @@ ol.interaction.Select.prototype.setMap = function(map) {
/**
* @return {ol.StyleFunction} Styles.
*/
ol.interaction.Select.getDefaultStyleFunction = function() {
var styles = ol.style.Style.createDefaultEditing();
ol.array.extend(styles[ol.geom.GeometryType.POLYGON],
styles[ol.geom.GeometryType.LINE_STRING]);
ol.array.extend(styles[ol.geom.GeometryType.GEOMETRY_COLLECTION],
styles[ol.geom.GeometryType.LINE_STRING]);
_ol_interaction_Select_.getDefaultStyleFunction = function() {
var styles = _ol_style_Style_.createDefaultEditing();
_ol_array_.extend(styles[_ol_geom_GeometryType_.POLYGON],
styles[_ol_geom_GeometryType_.LINE_STRING]);
_ol_array_.extend(styles[_ol_geom_GeometryType_.GEOMETRY_COLLECTION],
styles[_ol_geom_GeometryType_.LINE_STRING]);
return function(feature, resolution) {
if (!feature.getGeometry()) {
@@ -346,7 +347,7 @@ ol.interaction.Select.getDefaultStyleFunction = function() {
* @param {ol.Collection.Event} evt Event.
* @private
*/
ol.interaction.Select.prototype.addFeature_ = function(evt) {
_ol_interaction_Select_.prototype.addFeature_ = function(evt) {
var map = this.getMap();
if (map) {
map.skipFeature(/** @type {ol.Feature} */ (evt.element));
@@ -358,7 +359,7 @@ ol.interaction.Select.prototype.addFeature_ = function(evt) {
* @param {ol.Collection.Event} evt Event.
* @private
*/
ol.interaction.Select.prototype.removeFeature_ = function(evt) {
_ol_interaction_Select_.prototype.removeFeature_ = function(evt) {
var map = this.getMap();
if (map) {
map.unskipFeature(/** @type {ol.Feature} */ (evt.element));
@@ -370,8 +371,8 @@ ol.interaction.Select.prototype.removeFeature_ = function(evt) {
* @param {ol.Feature|ol.render.Feature} feature Feature.
* @private
*/
ol.interaction.Select.prototype.removeFeatureLayerAssociation_ = function(feature) {
var key = ol.getUid(feature);
_ol_interaction_Select_.prototype.removeFeatureLayerAssociation_ = function(feature) {
var key = _ol_.getUid(feature);
delete this.featureLayerAssociation_[key];
};
@@ -390,8 +391,8 @@ ol.interaction.Select.prototype.removeFeatureLayerAssociation_ = function(featur
* @extends {ol.events.Event}
* @constructor
*/
ol.interaction.Select.Event = function(type, selected, deselected, mapBrowserEvent) {
ol.events.Event.call(this, type);
_ol_interaction_Select_.Event = function(type, selected, deselected, mapBrowserEvent) {
_ol_events_Event_.call(this, type);
/**
* Selected features array.
@@ -414,14 +415,14 @@ ol.interaction.Select.Event = function(type, selected, deselected, mapBrowserEve
*/
this.mapBrowserEvent = mapBrowserEvent;
};
ol.inherits(ol.interaction.Select.Event, ol.events.Event);
_ol_.inherits(_ol_interaction_Select_.Event, _ol_events_Event_);
/**
* @enum {string}
* @private
*/
ol.interaction.Select.EventType_ = {
_ol_interaction_Select_.EventType_ = {
/**
* Triggered when feature(s) has been (de)selected.
* @event ol.interaction.Select.Event#select
@@ -429,3 +430,4 @@ ol.interaction.Select.EventType_ = {
*/
SELECT: 'select'
};
export default _ol_interaction_Select_;

View File

@@ -1,21 +1,21 @@
goog.provide('ol.interaction.Snap');
goog.require('ol');
goog.require('ol.Collection');
goog.require('ol.CollectionEventType');
goog.require('ol.coordinate');
goog.require('ol.events');
goog.require('ol.events.EventType');
goog.require('ol.extent');
goog.require('ol.functions');
goog.require('ol.geom.GeometryType');
goog.require('ol.geom.Polygon');
goog.require('ol.interaction.Pointer');
goog.require('ol.obj');
goog.require('ol.source.Vector');
goog.require('ol.source.VectorEventType');
goog.require('ol.structs.RBush');
/**
* @module ol/interaction/Snap
*/
import _ol_ from '../index.js';
import _ol_Collection_ from '../Collection.js';
import _ol_CollectionEventType_ from '../CollectionEventType.js';
import _ol_coordinate_ from '../coordinate.js';
import _ol_events_ from '../events.js';
import _ol_events_EventType_ from '../events/EventType.js';
import _ol_extent_ from '../extent.js';
import _ol_functions_ from '../functions.js';
import _ol_geom_GeometryType_ from '../geom/GeometryType.js';
import _ol_geom_Polygon_ from '../geom/Polygon.js';
import _ol_interaction_Pointer_ from '../interaction/Pointer.js';
import _ol_obj_ from '../obj.js';
import _ol_source_Vector_ from '../source/Vector.js';
import _ol_source_VectorEventType_ from '../source/VectorEventType.js';
import _ol_structs_RBush_ from '../structs/RBush.js';
/**
* @classdesc
@@ -39,12 +39,12 @@ goog.require('ol.structs.RBush');
* @param {olx.interaction.SnapOptions=} opt_options Options.
* @api
*/
ol.interaction.Snap = function(opt_options) {
var _ol_interaction_Snap_ = function(opt_options) {
ol.interaction.Pointer.call(this, {
handleEvent: ol.interaction.Snap.handleEvent_,
handleDownEvent: ol.functions.TRUE,
handleUpEvent: ol.interaction.Snap.handleUpEvent_
_ol_interaction_Pointer_.call(this, {
handleEvent: _ol_interaction_Snap_.handleEvent_,
handleDownEvent: _ol_functions_.TRUE,
handleUpEvent: _ol_interaction_Snap_.handleUpEvent_
});
var options = opt_options ? opt_options : {};
@@ -120,7 +120,7 @@ ol.interaction.Snap = function(opt_options) {
* @type {function(ol.SnapSegmentDataType, ol.SnapSegmentDataType): number}
* @private
*/
this.sortByDistance_ = ol.interaction.Snap.sortByDistance.bind(this);
this.sortByDistance_ = _ol_interaction_Snap_.sortByDistance.bind(this);
/**
@@ -128,7 +128,7 @@ ol.interaction.Snap = function(opt_options) {
* @type {ol.structs.RBush.<ol.SnapSegmentDataType>}
* @private
*/
this.rBush_ = new ol.structs.RBush();
this.rBush_ = new _ol_structs_RBush_();
/**
@@ -148,7 +148,8 @@ ol.interaction.Snap = function(opt_options) {
'Circle': this.writeCircleGeometry_
};
};
ol.inherits(ol.interaction.Snap, ol.interaction.Pointer);
_ol_.inherits(_ol_interaction_Snap_, _ol_interaction_Pointer_);
/**
@@ -158,23 +159,23 @@ ol.inherits(ol.interaction.Snap, ol.interaction.Pointer);
* Defaults to `true`.
* @api
*/
ol.interaction.Snap.prototype.addFeature = function(feature, opt_listen) {
_ol_interaction_Snap_.prototype.addFeature = function(feature, opt_listen) {
var listen = opt_listen !== undefined ? opt_listen : true;
var feature_uid = ol.getUid(feature);
var feature_uid = _ol_.getUid(feature);
var geometry = feature.getGeometry();
if (geometry) {
var segmentWriter = this.SEGMENT_WRITERS_[geometry.getType()];
if (segmentWriter) {
this.indexedFeaturesExtents_[feature_uid] = geometry.getExtent(
ol.extent.createEmpty());
_ol_extent_.createEmpty());
segmentWriter.call(this, feature, geometry);
}
}
if (listen) {
this.featureChangeListenerKeys_[feature_uid] = ol.events.listen(
this.featureChangeListenerKeys_[feature_uid] = _ol_events_.listen(
feature,
ol.events.EventType.CHANGE,
_ol_events_EventType_.CHANGE,
this.handleFeatureChange_, this);
}
};
@@ -184,7 +185,7 @@ ol.interaction.Snap.prototype.addFeature = function(feature, opt_listen) {
* @param {ol.Feature} feature Feature.
* @private
*/
ol.interaction.Snap.prototype.forEachFeatureAdd_ = function(feature) {
_ol_interaction_Snap_.prototype.forEachFeatureAdd_ = function(feature) {
this.addFeature(feature);
};
@@ -193,7 +194,7 @@ ol.interaction.Snap.prototype.forEachFeatureAdd_ = function(feature) {
* @param {ol.Feature} feature Feature.
* @private
*/
ol.interaction.Snap.prototype.forEachFeatureRemove_ = function(feature) {
_ol_interaction_Snap_.prototype.forEachFeatureRemove_ = function(feature) {
this.removeFeature(feature);
};
@@ -202,7 +203,7 @@ ol.interaction.Snap.prototype.forEachFeatureRemove_ = function(feature) {
* @return {ol.Collection.<ol.Feature>|Array.<ol.Feature>} Features.
* @private
*/
ol.interaction.Snap.prototype.getFeatures_ = function() {
_ol_interaction_Snap_.prototype.getFeatures_ = function() {
var features;
if (this.features_) {
features = this.features_;
@@ -217,11 +218,11 @@ ol.interaction.Snap.prototype.getFeatures_ = function() {
* @param {ol.source.Vector.Event|ol.Collection.Event} evt Event.
* @private
*/
ol.interaction.Snap.prototype.handleFeatureAdd_ = function(evt) {
_ol_interaction_Snap_.prototype.handleFeatureAdd_ = function(evt) {
var feature;
if (evt instanceof ol.source.Vector.Event) {
if (evt instanceof _ol_source_Vector_.Event) {
feature = evt.feature;
} else if (evt instanceof ol.Collection.Event) {
} else if (evt instanceof _ol_Collection_.Event) {
feature = evt.element;
}
this.addFeature(/** @type {ol.Feature} */ (feature));
@@ -232,11 +233,11 @@ ol.interaction.Snap.prototype.handleFeatureAdd_ = function(evt) {
* @param {ol.source.Vector.Event|ol.Collection.Event} evt Event.
* @private
*/
ol.interaction.Snap.prototype.handleFeatureRemove_ = function(evt) {
_ol_interaction_Snap_.prototype.handleFeatureRemove_ = function(evt) {
var feature;
if (evt instanceof ol.source.Vector.Event) {
if (evt instanceof _ol_source_Vector_.Event) {
feature = evt.feature;
} else if (evt instanceof ol.Collection.Event) {
} else if (evt instanceof _ol_Collection_.Event) {
feature = evt.element;
}
this.removeFeature(/** @type {ol.Feature} */ (feature));
@@ -247,10 +248,10 @@ ol.interaction.Snap.prototype.handleFeatureRemove_ = function(evt) {
* @param {ol.events.Event} evt Event.
* @private
*/
ol.interaction.Snap.prototype.handleFeatureChange_ = function(evt) {
_ol_interaction_Snap_.prototype.handleFeatureChange_ = function(evt) {
var feature = /** @type {ol.Feature} */ (evt.target);
if (this.handlingDownUpSequence) {
var uid = ol.getUid(feature);
var uid = _ol_.getUid(feature);
if (!(uid in this.pendingFeatures_)) {
this.pendingFeatures_[uid] = feature;
}
@@ -267,9 +268,9 @@ ol.interaction.Snap.prototype.handleFeatureChange_ = function(evt) {
* or not. Defaults to `true`.
* @api
*/
ol.interaction.Snap.prototype.removeFeature = function(feature, opt_unlisten) {
_ol_interaction_Snap_.prototype.removeFeature = function(feature, opt_unlisten) {
var unlisten = opt_unlisten !== undefined ? opt_unlisten : true;
var feature_uid = ol.getUid(feature);
var feature_uid = _ol_.getUid(feature);
var extent = this.indexedFeaturesExtents_[feature_uid];
if (extent) {
var rBush = this.rBush_;
@@ -285,7 +286,7 @@ ol.interaction.Snap.prototype.removeFeature = function(feature, opt_unlisten) {
}
if (unlisten) {
ol.events.unlistenByKey(this.featureChangeListenerKeys_[feature_uid]);
_ol_events_.unlistenByKey(this.featureChangeListenerKeys_[feature_uid]);
delete this.featureChangeListenerKeys_[feature_uid];
}
};
@@ -294,31 +295,31 @@ ol.interaction.Snap.prototype.removeFeature = function(feature, opt_unlisten) {
/**
* @inheritDoc
*/
ol.interaction.Snap.prototype.setMap = function(map) {
_ol_interaction_Snap_.prototype.setMap = function(map) {
var currentMap = this.getMap();
var keys = this.featuresListenerKeys_;
var features = this.getFeatures_();
if (currentMap) {
keys.forEach(ol.events.unlistenByKey);
keys.forEach(_ol_events_.unlistenByKey);
keys.length = 0;
features.forEach(this.forEachFeatureRemove_, this);
}
ol.interaction.Pointer.prototype.setMap.call(this, map);
_ol_interaction_Pointer_.prototype.setMap.call(this, map);
if (map) {
if (this.features_) {
keys.push(
ol.events.listen(this.features_, ol.CollectionEventType.ADD,
_ol_events_.listen(this.features_, _ol_CollectionEventType_.ADD,
this.handleFeatureAdd_, this),
ol.events.listen(this.features_, ol.CollectionEventType.REMOVE,
_ol_events_.listen(this.features_, _ol_CollectionEventType_.REMOVE,
this.handleFeatureRemove_, this)
);
} else if (this.source_) {
keys.push(
ol.events.listen(this.source_, ol.source.VectorEventType.ADDFEATURE,
_ol_events_.listen(this.source_, _ol_source_VectorEventType_.ADDFEATURE,
this.handleFeatureAdd_, this),
ol.events.listen(this.source_, ol.source.VectorEventType.REMOVEFEATURE,
_ol_events_.listen(this.source_, _ol_source_VectorEventType_.REMOVEFEATURE,
this.handleFeatureRemove_, this)
);
}
@@ -330,7 +331,7 @@ ol.interaction.Snap.prototype.setMap = function(map) {
/**
* @inheritDoc
*/
ol.interaction.Snap.prototype.shouldStopEvent = ol.functions.FALSE;
_ol_interaction_Snap_.prototype.shouldStopEvent = _ol_functions_.FALSE;
/**
@@ -339,13 +340,13 @@ ol.interaction.Snap.prototype.shouldStopEvent = ol.functions.FALSE;
* @param {ol.PluggableMap} map Map.
* @return {ol.SnapResultType} Snap result
*/
ol.interaction.Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) {
_ol_interaction_Snap_.prototype.snapTo = function(pixel, pixelCoordinate, map) {
var lowerLeft = map.getCoordinateFromPixel(
[pixel[0] - this.pixelTolerance_, pixel[1] + this.pixelTolerance_]);
var upperRight = map.getCoordinateFromPixel(
[pixel[0] + this.pixelTolerance_, pixel[1] - this.pixelTolerance_]);
var box = ol.extent.boundingExtent([lowerLeft, upperRight]);
var box = _ol_extent_.boundingExtent([lowerLeft, upperRight]);
var segments = this.rBush_.getInExtent(box);
@@ -353,7 +354,7 @@ ol.interaction.Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) {
if (this.vertex_ && !this.edge_) {
segments = segments.filter(function(segment) {
return segment.feature.getGeometry().getType() !==
ol.geom.GeometryType.CIRCLE;
_ol_geom_GeometryType_.CIRCLE;
});
}
@@ -367,12 +368,12 @@ ol.interaction.Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) {
segments.sort(this.sortByDistance_);
var closestSegment = segments[0].segment;
var isCircle = segments[0].feature.getGeometry().getType() ===
ol.geom.GeometryType.CIRCLE;
_ol_geom_GeometryType_.CIRCLE;
if (this.vertex_ && !this.edge_) {
pixel1 = map.getPixelFromCoordinate(closestSegment[0]);
pixel2 = map.getPixelFromCoordinate(closestSegment[1]);
squaredDist1 = ol.coordinate.squaredDistance(pixel, pixel1);
squaredDist2 = ol.coordinate.squaredDistance(pixel, pixel2);
squaredDist1 = _ol_coordinate_.squaredDistance(pixel, pixel1);
squaredDist2 = _ol_coordinate_.squaredDistance(pixel, pixel2);
dist = Math.sqrt(Math.min(squaredDist1, squaredDist2));
snappedToVertex = dist <= this.pixelTolerance_;
if (snappedToVertex) {
@@ -383,20 +384,20 @@ ol.interaction.Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) {
}
} else if (this.edge_) {
if (isCircle) {
vertex = ol.coordinate.closestOnCircle(pixelCoordinate,
vertex = _ol_coordinate_.closestOnCircle(pixelCoordinate,
/** @type {ol.geom.Circle} */ (segments[0].feature.getGeometry()));
} else {
vertex = (ol.coordinate.closestOnSegment(pixelCoordinate,
vertex = (_ol_coordinate_.closestOnSegment(pixelCoordinate,
closestSegment));
}
vertexPixel = map.getPixelFromCoordinate(vertex);
if (ol.coordinate.distance(pixel, vertexPixel) <= this.pixelTolerance_) {
if (_ol_coordinate_.distance(pixel, vertexPixel) <= this.pixelTolerance_) {
snapped = true;
if (this.vertex_ && !isCircle) {
pixel1 = map.getPixelFromCoordinate(closestSegment[0]);
pixel2 = map.getPixelFromCoordinate(closestSegment[1]);
squaredDist1 = ol.coordinate.squaredDistance(vertexPixel, pixel1);
squaredDist2 = ol.coordinate.squaredDistance(vertexPixel, pixel2);
squaredDist1 = _ol_coordinate_.squaredDistance(vertexPixel, pixel1);
squaredDist2 = _ol_coordinate_.squaredDistance(vertexPixel, pixel2);
dist = Math.sqrt(Math.min(squaredDist1, squaredDist2));
snappedToVertex = dist <= this.pixelTolerance_;
if (snappedToVertex) {
@@ -423,7 +424,7 @@ ol.interaction.Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) {
* @param {ol.Feature} feature Feature
* @private
*/
ol.interaction.Snap.prototype.updateFeature_ = function(feature) {
_ol_interaction_Snap_.prototype.updateFeature_ = function(feature) {
this.removeFeature(feature, false);
this.addFeature(feature, false);
};
@@ -434,8 +435,8 @@ ol.interaction.Snap.prototype.updateFeature_ = function(feature) {
* @param {ol.geom.Circle} geometry Geometry.
* @private
*/
ol.interaction.Snap.prototype.writeCircleGeometry_ = function(feature, geometry) {
var polygon = ol.geom.Polygon.fromCircle(geometry);
_ol_interaction_Snap_.prototype.writeCircleGeometry_ = function(feature, geometry) {
var polygon = _ol_geom_Polygon_.fromCircle(geometry);
var coordinates = polygon.getCoordinates()[0];
var i, ii, segment, segmentData;
for (i = 0, ii = coordinates.length - 1; i < ii; ++i) {
@@ -444,7 +445,7 @@ ol.interaction.Snap.prototype.writeCircleGeometry_ = function(feature, geometry)
feature: feature,
segment: segment
});
this.rBush_.insert(ol.extent.boundingExtent(segment), segmentData);
this.rBush_.insert(_ol_extent_.boundingExtent(segment), segmentData);
}
};
@@ -454,7 +455,7 @@ ol.interaction.Snap.prototype.writeCircleGeometry_ = function(feature, geometry)
* @param {ol.geom.GeometryCollection} geometry Geometry.
* @private
*/
ol.interaction.Snap.prototype.writeGeometryCollectionGeometry_ = function(feature, geometry) {
_ol_interaction_Snap_.prototype.writeGeometryCollectionGeometry_ = function(feature, geometry) {
var i, geometries = geometry.getGeometriesArray();
for (i = 0; i < geometries.length; ++i) {
var segmentWriter = this.SEGMENT_WRITERS_[geometries[i].getType()];
@@ -470,7 +471,7 @@ ol.interaction.Snap.prototype.writeGeometryCollectionGeometry_ = function(featur
* @param {ol.geom.LineString} geometry Geometry.
* @private
*/
ol.interaction.Snap.prototype.writeLineStringGeometry_ = function(feature, geometry) {
_ol_interaction_Snap_.prototype.writeLineStringGeometry_ = function(feature, geometry) {
var coordinates = geometry.getCoordinates();
var i, ii, segment, segmentData;
for (i = 0, ii = coordinates.length - 1; i < ii; ++i) {
@@ -479,7 +480,7 @@ ol.interaction.Snap.prototype.writeLineStringGeometry_ = function(feature, geome
feature: feature,
segment: segment
});
this.rBush_.insert(ol.extent.boundingExtent(segment), segmentData);
this.rBush_.insert(_ol_extent_.boundingExtent(segment), segmentData);
}
};
@@ -489,7 +490,7 @@ ol.interaction.Snap.prototype.writeLineStringGeometry_ = function(feature, geome
* @param {ol.geom.MultiLineString} geometry Geometry.
* @private
*/
ol.interaction.Snap.prototype.writeMultiLineStringGeometry_ = function(feature, geometry) {
_ol_interaction_Snap_.prototype.writeMultiLineStringGeometry_ = function(feature, geometry) {
var lines = geometry.getCoordinates();
var coordinates, i, ii, j, jj, segment, segmentData;
for (j = 0, jj = lines.length; j < jj; ++j) {
@@ -500,7 +501,7 @@ ol.interaction.Snap.prototype.writeMultiLineStringGeometry_ = function(feature,
feature: feature,
segment: segment
});
this.rBush_.insert(ol.extent.boundingExtent(segment), segmentData);
this.rBush_.insert(_ol_extent_.boundingExtent(segment), segmentData);
}
}
};
@@ -511,7 +512,7 @@ ol.interaction.Snap.prototype.writeMultiLineStringGeometry_ = function(feature,
* @param {ol.geom.MultiPoint} geometry Geometry.
* @private
*/
ol.interaction.Snap.prototype.writeMultiPointGeometry_ = function(feature, geometry) {
_ol_interaction_Snap_.prototype.writeMultiPointGeometry_ = function(feature, geometry) {
var points = geometry.getCoordinates();
var coordinates, i, ii, segmentData;
for (i = 0, ii = points.length; i < ii; ++i) {
@@ -530,7 +531,7 @@ ol.interaction.Snap.prototype.writeMultiPointGeometry_ = function(feature, geome
* @param {ol.geom.MultiPolygon} geometry Geometry.
* @private
*/
ol.interaction.Snap.prototype.writeMultiPolygonGeometry_ = function(feature, geometry) {
_ol_interaction_Snap_.prototype.writeMultiPolygonGeometry_ = function(feature, geometry) {
var polygons = geometry.getCoordinates();
var coordinates, i, ii, j, jj, k, kk, rings, segment, segmentData;
for (k = 0, kk = polygons.length; k < kk; ++k) {
@@ -543,7 +544,7 @@ ol.interaction.Snap.prototype.writeMultiPolygonGeometry_ = function(feature, geo
feature: feature,
segment: segment
});
this.rBush_.insert(ol.extent.boundingExtent(segment), segmentData);
this.rBush_.insert(_ol_extent_.boundingExtent(segment), segmentData);
}
}
}
@@ -555,7 +556,7 @@ ol.interaction.Snap.prototype.writeMultiPolygonGeometry_ = function(feature, geo
* @param {ol.geom.Point} geometry Geometry.
* @private
*/
ol.interaction.Snap.prototype.writePointGeometry_ = function(feature, geometry) {
_ol_interaction_Snap_.prototype.writePointGeometry_ = function(feature, geometry) {
var coordinates = geometry.getCoordinates();
var segmentData = /** @type {ol.SnapSegmentDataType} */ ({
feature: feature,
@@ -570,7 +571,7 @@ ol.interaction.Snap.prototype.writePointGeometry_ = function(feature, geometry)
* @param {ol.geom.Polygon} geometry Geometry.
* @private
*/
ol.interaction.Snap.prototype.writePolygonGeometry_ = function(feature, geometry) {
_ol_interaction_Snap_.prototype.writePolygonGeometry_ = function(feature, geometry) {
var rings = geometry.getCoordinates();
var coordinates, i, ii, j, jj, segment, segmentData;
for (j = 0, jj = rings.length; j < jj; ++j) {
@@ -581,7 +582,7 @@ ol.interaction.Snap.prototype.writePolygonGeometry_ = function(feature, geometry
feature: feature,
segment: segment
});
this.rBush_.insert(ol.extent.boundingExtent(segment), segmentData);
this.rBush_.insert(_ol_extent_.boundingExtent(segment), segmentData);
}
}
};
@@ -594,13 +595,13 @@ ol.interaction.Snap.prototype.writePolygonGeometry_ = function(feature, geometry
* @this {ol.interaction.Snap}
* @private
*/
ol.interaction.Snap.handleEvent_ = function(evt) {
_ol_interaction_Snap_.handleEvent_ = function(evt) {
var result = this.snapTo(evt.pixel, evt.coordinate, evt.map);
if (result.snapped) {
evt.coordinate = result.vertex.slice(0, 2);
evt.pixel = result.vertexPixel;
}
return ol.interaction.Pointer.handleEvent.call(this, evt);
return _ol_interaction_Pointer_.handleEvent.call(this, evt);
};
@@ -610,8 +611,8 @@ ol.interaction.Snap.handleEvent_ = function(evt) {
* @this {ol.interaction.Snap}
* @private
*/
ol.interaction.Snap.handleUpEvent_ = function(evt) {
var featuresToUpdate = ol.obj.getValues(this.pendingFeatures_);
_ol_interaction_Snap_.handleUpEvent_ = function(evt) {
var featuresToUpdate = _ol_obj_.getValues(this.pendingFeatures_);
if (featuresToUpdate.length) {
featuresToUpdate.forEach(this.updateFeature_, this);
this.pendingFeatures_ = {};
@@ -627,9 +628,10 @@ ol.interaction.Snap.handleUpEvent_ = function(evt) {
* @return {number} The difference in distance.
* @this {ol.interaction.Snap}
*/
ol.interaction.Snap.sortByDistance = function(a, b) {
return ol.coordinate.squaredDistanceToSegment(
_ol_interaction_Snap_.sortByDistance = function(a, b) {
return _ol_coordinate_.squaredDistanceToSegment(
this.pixelCoordinate_, a.segment) -
ol.coordinate.squaredDistanceToSegment(
_ol_coordinate_.squaredDistanceToSegment(
this.pixelCoordinate_, b.segment);
};
export default _ol_interaction_Snap_;

View File

@@ -1,16 +1,16 @@
goog.provide('ol.interaction.Translate');
goog.require('ol');
goog.require('ol.Collection');
goog.require('ol.Object');
goog.require('ol.events');
goog.require('ol.events.Event');
goog.require('ol.functions');
goog.require('ol.array');
goog.require('ol.interaction.Pointer');
goog.require('ol.interaction.Property');
goog.require('ol.interaction.TranslateEventType');
/**
* @module ol/interaction/Translate
*/
import _ol_ from '../index.js';
import _ol_Collection_ from '../Collection.js';
import _ol_Object_ from '../Object.js';
import _ol_events_ from '../events.js';
import _ol_events_Event_ from '../events/Event.js';
import _ol_functions_ from '../functions.js';
import _ol_array_ from '../array.js';
import _ol_interaction_Pointer_ from '../interaction/Pointer.js';
import _ol_interaction_Property_ from '../interaction/Property.js';
import _ol_interaction_TranslateEventType_ from '../interaction/TranslateEventType.js';
/**
* @classdesc
@@ -22,12 +22,12 @@ goog.require('ol.interaction.TranslateEventType');
* @param {olx.interaction.TranslateOptions=} opt_options Options.
* @api
*/
ol.interaction.Translate = function(opt_options) {
ol.interaction.Pointer.call(this, {
handleDownEvent: ol.interaction.Translate.handleDownEvent_,
handleDragEvent: ol.interaction.Translate.handleDragEvent_,
handleMoveEvent: ol.interaction.Translate.handleMoveEvent_,
handleUpEvent: ol.interaction.Translate.handleUpEvent_
var _ol_interaction_Translate_ = function(opt_options) {
_ol_interaction_Pointer_.call(this, {
handleDownEvent: _ol_interaction_Translate_.handleDownEvent_,
handleDragEvent: _ol_interaction_Translate_.handleDragEvent_,
handleMoveEvent: _ol_interaction_Translate_.handleMoveEvent_,
handleUpEvent: _ol_interaction_Translate_.handleUpEvent_
});
var options = opt_options ? opt_options : {};
@@ -54,11 +54,11 @@ ol.interaction.Translate = function(opt_options) {
} else {
var layers = options.layers;
layerFilter = function(layer) {
return ol.array.includes(layers, layer);
return _ol_array_.includes(layers, layer);
};
}
} else {
layerFilter = ol.functions.TRUE;
layerFilter = _ol_functions_.TRUE;
}
/**
@@ -79,12 +79,13 @@ ol.interaction.Translate = function(opt_options) {
*/
this.lastFeature_ = null;
ol.events.listen(this,
ol.Object.getChangeEventType(ol.interaction.Property.ACTIVE),
_ol_events_.listen(this,
_ol_Object_.getChangeEventType(_ol_interaction_Property_.ACTIVE),
this.handleActiveChanged_, this);
};
ol.inherits(ol.interaction.Translate, ol.interaction.Pointer);
_ol_.inherits(_ol_interaction_Translate_, _ol_interaction_Pointer_);
/**
@@ -93,17 +94,17 @@ ol.inherits(ol.interaction.Translate, ol.interaction.Pointer);
* @this {ol.interaction.Translate}
* @private
*/
ol.interaction.Translate.handleDownEvent_ = function(event) {
_ol_interaction_Translate_.handleDownEvent_ = function(event) {
this.lastFeature_ = this.featuresAtPixel_(event.pixel, event.map);
if (!this.lastCoordinate_ && this.lastFeature_) {
this.lastCoordinate_ = event.coordinate;
ol.interaction.Translate.handleMoveEvent_.call(this, event);
_ol_interaction_Translate_.handleMoveEvent_.call(this, event);
var features = this.features_ || new ol.Collection([this.lastFeature_]);
var features = this.features_ || new _ol_Collection_([this.lastFeature_]);
this.dispatchEvent(
new ol.interaction.Translate.Event(
ol.interaction.TranslateEventType.TRANSLATESTART, features,
new _ol_interaction_Translate_.Event(
_ol_interaction_TranslateEventType_.TRANSLATESTART, features,
event.coordinate));
return true;
}
@@ -117,16 +118,16 @@ ol.interaction.Translate.handleDownEvent_ = function(event) {
* @this {ol.interaction.Translate}
* @private
*/
ol.interaction.Translate.handleUpEvent_ = function(event) {
_ol_interaction_Translate_.handleUpEvent_ = function(event) {
if (this.lastCoordinate_) {
this.lastCoordinate_ = null;
ol.interaction.Translate.handleMoveEvent_.call(this, event);
_ol_interaction_Translate_.handleMoveEvent_.call(this, event);
var features = this.features_ || new ol.Collection([this.lastFeature_]);
var features = this.features_ || new _ol_Collection_([this.lastFeature_]);
this.dispatchEvent(
new ol.interaction.Translate.Event(
ol.interaction.TranslateEventType.TRANSLATEEND, features,
new _ol_interaction_Translate_.Event(
_ol_interaction_TranslateEventType_.TRANSLATEEND, features,
event.coordinate));
return true;
}
@@ -139,13 +140,13 @@ ol.interaction.Translate.handleUpEvent_ = function(event) {
* @this {ol.interaction.Translate}
* @private
*/
ol.interaction.Translate.handleDragEvent_ = function(event) {
_ol_interaction_Translate_.handleDragEvent_ = function(event) {
if (this.lastCoordinate_) {
var newCoordinate = event.coordinate;
var deltaX = newCoordinate[0] - this.lastCoordinate_[0];
var deltaY = newCoordinate[1] - this.lastCoordinate_[1];
var features = this.features_ || new ol.Collection([this.lastFeature_]);
var features = this.features_ || new _ol_Collection_([this.lastFeature_]);
features.forEach(function(feature) {
var geom = feature.getGeometry();
@@ -155,8 +156,8 @@ ol.interaction.Translate.handleDragEvent_ = function(event) {
this.lastCoordinate_ = newCoordinate;
this.dispatchEvent(
new ol.interaction.Translate.Event(
ol.interaction.TranslateEventType.TRANSLATING, features,
new _ol_interaction_Translate_.Event(
_ol_interaction_TranslateEventType_.TRANSLATING, features,
newCoordinate));
}
};
@@ -167,7 +168,7 @@ ol.interaction.Translate.handleDragEvent_ = function(event) {
* @this {ol.interaction.Translate}
* @private
*/
ol.interaction.Translate.handleMoveEvent_ = function(event) {
_ol_interaction_Translate_.handleMoveEvent_ = function(event) {
var elem = event.map.getViewport();
// Change the cursor to grab/grabbing if hovering any of the features managed
@@ -190,11 +191,11 @@ ol.interaction.Translate.handleMoveEvent_ = function(event) {
* coordinates.
* @private
*/
ol.interaction.Translate.prototype.featuresAtPixel_ = function(pixel, map) {
_ol_interaction_Translate_.prototype.featuresAtPixel_ = function(pixel, map) {
return map.forEachFeatureAtPixel(pixel,
function(feature) {
if (!this.features_ ||
ol.array.includes(this.features_.getArray(), feature)) {
_ol_array_.includes(this.features_.getArray(), feature)) {
return feature;
}
}.bind(this), {
@@ -209,7 +210,7 @@ ol.interaction.Translate.prototype.featuresAtPixel_ = function(pixel, map) {
* @returns {number} Hit tolerance in pixels.
* @api
*/
ol.interaction.Translate.prototype.getHitTolerance = function() {
_ol_interaction_Translate_.prototype.getHitTolerance = function() {
return this.hitTolerance_;
};
@@ -221,7 +222,7 @@ ol.interaction.Translate.prototype.getHitTolerance = function() {
* @param {number} hitTolerance Hit tolerance in pixels.
* @api
*/
ol.interaction.Translate.prototype.setHitTolerance = function(hitTolerance) {
_ol_interaction_Translate_.prototype.setHitTolerance = function(hitTolerance) {
this.hitTolerance_ = hitTolerance;
};
@@ -229,9 +230,9 @@ ol.interaction.Translate.prototype.setHitTolerance = function(hitTolerance) {
/**
* @inheritDoc
*/
ol.interaction.Translate.prototype.setMap = function(map) {
_ol_interaction_Translate_.prototype.setMap = function(map) {
var oldMap = this.getMap();
ol.interaction.Pointer.prototype.setMap.call(this, map);
_ol_interaction_Pointer_.prototype.setMap.call(this, map);
this.updateState_(oldMap);
};
@@ -239,7 +240,7 @@ ol.interaction.Translate.prototype.setMap = function(map) {
/**
* @private
*/
ol.interaction.Translate.prototype.handleActiveChanged_ = function() {
_ol_interaction_Translate_.prototype.handleActiveChanged_ = function() {
this.updateState_(null);
};
@@ -248,7 +249,7 @@ ol.interaction.Translate.prototype.handleActiveChanged_ = function() {
* @param {ol.PluggableMap} oldMap Old map.
* @private
*/
ol.interaction.Translate.prototype.updateState_ = function(oldMap) {
_ol_interaction_Translate_.prototype.updateState_ = function(oldMap) {
var map = this.getMap();
var active = this.getActive();
if (!map || !active) {
@@ -273,9 +274,9 @@ ol.interaction.Translate.prototype.updateState_ = function(oldMap) {
* @param {ol.Collection.<ol.Feature>} features The features translated.
* @param {ol.Coordinate} coordinate The event coordinate.
*/
ol.interaction.Translate.Event = function(type, features, coordinate) {
_ol_interaction_Translate_.Event = function(type, features, coordinate) {
ol.events.Event.call(this, type);
_ol_events_Event_.call(this, type);
/**
* The features being translated.
@@ -292,4 +293,5 @@ ol.interaction.Translate.Event = function(type, features, coordinate) {
*/
this.coordinate = coordinate;
};
ol.inherits(ol.interaction.Translate.Event, ol.events.Event);
_ol_.inherits(_ol_interaction_Translate_.Event, _ol_events_Event_);
export default _ol_interaction_Translate_;

View File

@@ -1,10 +1,10 @@
goog.provide('ol.interaction.TranslateEventType');
/**
* @module ol/interaction/TranslateEventType
*/
/**
* @enum {string}
*/
ol.interaction.TranslateEventType = {
var _ol_interaction_TranslateEventType_ = {
/**
* Triggered upon feature translation start.
* @event ol.interaction.Translate.Event#translatestart
@@ -24,3 +24,5 @@ ol.interaction.TranslateEventType = {
*/
TRANSLATEEND: 'translateend'
};
export default _ol_interaction_TranslateEventType_;