Rename _ol_interaction_Draw_ to Draw

This commit is contained in:
Marc Jansen
2017-12-15 10:35:18 +01:00
committed by Tim Schaub
parent b92118b5ab
commit 4868098495
11 changed files with 108 additions and 107 deletions

View File

@@ -1,6 +1,6 @@
import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js';
import _ol_interaction_Draw_ from '../src/ol/interaction/Draw.js';
import Draw from '../src/ol/interaction/Draw.js';
import _ol_interaction_Modify_ from '../src/ol/interaction/Modify.js';
import _ol_interaction_Snap_ from '../src/ol/interaction/Snap.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
@@ -52,7 +52,7 @@ var draw, snap; // global so we can remove them later
var typeSelect = document.getElementById('type');
function addInteractions() {
draw = new _ol_interaction_Draw_({
draw = new Draw({
source: source,
type: typeSelect.value
});

View File

@@ -1,6 +1,6 @@
import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js';
import _ol_interaction_Draw_ from '../src/ol/interaction/Draw.js';
import Draw from '../src/ol/interaction/Draw.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_layer_Vector_ from '../src/ol/layer/Vector.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js';
@@ -31,7 +31,7 @@ var draw; // global so we can remove it later
function addInteraction() {
var value = typeSelect.value;
if (value !== 'None') {
draw = new _ol_interaction_Draw_({
draw = new Draw({
source: source,
type: typeSelect.value
});

View File

@@ -1,6 +1,6 @@
import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js';
import _ol_interaction_Draw_ from '../src/ol/interaction/Draw.js';
import Draw from '../src/ol/interaction/Draw.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_layer_Vector_ from '../src/ol/layer/Vector.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js';
@@ -31,7 +31,7 @@ var draw; // global so we can remove it later
function addInteraction() {
var value = typeSelect.value;
if (value !== 'None') {
draw = new _ol_interaction_Draw_({
draw = new Draw({
source: source,
type: typeSelect.value,
freehand: true

View File

@@ -1,7 +1,7 @@
import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js';
import Polygon from '../src/ol/geom/Polygon.js';
import _ol_interaction_Draw_ from '../src/ol/interaction/Draw.js';
import Draw from '../src/ol/interaction/Draw.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_layer_Vector_ from '../src/ol/layer/Vector.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js';
@@ -35,10 +35,10 @@ function addInteraction() {
var geometryFunction;
if (value === 'Square') {
value = 'Circle';
geometryFunction = _ol_interaction_Draw_.createRegularPolygon(4);
geometryFunction = Draw.createRegularPolygon(4);
} else if (value === 'Box') {
value = 'Circle';
geometryFunction = _ol_interaction_Draw_.createBox();
geometryFunction = Draw.createBox();
} else if (value === 'Star') {
value = 'Circle';
geometryFunction = function(coordinates, geometry) {
@@ -65,7 +65,7 @@ function addInteraction() {
return geometry;
};
}
draw = new _ol_interaction_Draw_({
draw = new Draw({
source: source,
type: value,
geometryFunction: geometryFunction

View File

@@ -1,7 +1,7 @@
import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js';
import Point from '../src/ol/geom/Point.js';
import _ol_interaction_Draw_ from '../src/ol/interaction/Draw.js';
import Draw from '../src/ol/interaction/Draw.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_layer_Vector_ from '../src/ol/layer/Vector.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js';
@@ -60,7 +60,7 @@ var map = new _ol_Map_({
})
});
map.addInteraction(new _ol_interaction_Draw_({
map.addInteraction(new Draw({
source: source,
type: 'LineString'
}));

View File

@@ -5,7 +5,7 @@ import _ol_Sphere_ from '../src/ol/Sphere.js';
import _ol_View_ from '../src/ol/View.js';
import LineString from '../src/ol/geom/LineString.js';
import Polygon from '../src/ol/geom/Polygon.js';
import _ol_interaction_Draw_ from '../src/ol/interaction/Draw.js';
import Draw from '../src/ol/interaction/Draw.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_layer_Vector_ from '../src/ol/layer/Vector.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js';
@@ -177,7 +177,7 @@ var formatArea = function(polygon) {
function addInteraction() {
var type = (typeSelect.value == 'area' ? 'Polygon' : 'LineString');
draw = new _ol_interaction_Draw_({
draw = new Draw({
source: source,
type: type,
style: new _ol_style_Style_({

View File

@@ -1,6 +1,6 @@
import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js';
import _ol_interaction_Draw_ from '../src/ol/interaction/Draw.js';
import Draw from '../src/ol/interaction/Draw.js';
import _ol_interaction_Modify_ from '../src/ol/interaction/Modify.js';
import _ol_interaction_Select_ from '../src/ol/interaction/Select.js';
import _ol_interaction_Snap_ from '../src/ol/interaction/Snap.js';
@@ -73,7 +73,7 @@ Modify.init();
var optionsForm = document.getElementById('options-form');
var Draw = {
var ExampleDraw = {
init: function() {
map.addInteraction(this.Point);
this.Point.setActive(false);
@@ -84,19 +84,19 @@ var Draw = {
map.addInteraction(this.Circle);
this.Circle.setActive(false);
},
Point: new _ol_interaction_Draw_({
Point: new Draw({
source: vector.getSource(),
type: 'Point'
}),
LineString: new _ol_interaction_Draw_({
LineString: new Draw({
source: vector.getSource(),
type: 'LineString'
}),
Polygon: new _ol_interaction_Draw_({
Polygon: new Draw({
source: vector.getSource(),
type: 'Polygon'
}),
Circle: new _ol_interaction_Draw_({
Circle: new Draw({
source: vector.getSource(),
type: 'Circle'
}),
@@ -115,7 +115,7 @@ var Draw = {
}
}
};
Draw.init();
ExampleDraw.init();
/**

View File

@@ -7,7 +7,7 @@ import _ol_View_ from '../src/ol/View.js';
import Point from '../src/ol/geom/Point.js';
import LineString from '../src/ol/geom/LineString.js';
import Polygon from '../src/ol/geom/Polygon.js';
import _ol_interaction_Draw_ from '../src/ol/interaction/Draw.js';
import Draw from '../src/ol/interaction/Draw.js';
import _ol_interaction_Snap_ from '../src/ol/interaction/Snap.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_layer_Vector_ from '../src/ol/layer/Vector.js';
@@ -204,7 +204,7 @@ function onDrawend(e) {
}
}
var draw = new _ol_interaction_Draw_({
var draw = new Draw({
type: 'LineString'
});
draw.on('drawend', onDrawend);

View File

@@ -2,7 +2,7 @@ import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js';
import _ol_format_EsriJSON_ from '../src/ol/format/EsriJSON.js';
import _ol_interaction_ from '../src/ol/interaction.js';
import _ol_interaction_Draw_ from '../src/ol/interaction/Draw.js';
import Draw from '../src/ol/interaction/Draw.js';
import _ol_interaction_Modify_ from '../src/ol/interaction/Modify.js';
import _ol_interaction_Select_ from '../src/ol/interaction/Select.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
@@ -62,7 +62,7 @@ var raster = new _ol_layer_Tile_({
})
});
var draw = new _ol_interaction_Draw_({
var draw = new Draw({
source: vectorSource,
type: 'Polygon'
});

View File

@@ -36,12 +36,12 @@ import _ol_style_Style_ from '../style/Style.js';
* @param {olx.interaction.DrawOptions} options Options.
* @api
*/
var _ol_interaction_Draw_ = function(options) {
var Draw = function(options) {
_ol_interaction_Pointer_.call(this, {
handleDownEvent: _ol_interaction_Draw_.handleDownEvent_,
handleEvent: _ol_interaction_Draw_.handleEvent,
handleUpEvent: _ol_interaction_Draw_.handleUpEvent_
handleDownEvent: Draw.handleDownEvent_,
handleEvent: Draw.handleEvent,
handleUpEvent: Draw.handleUpEvent_
});
/**
@@ -95,7 +95,7 @@ var _ol_interaction_Draw_ = function(options) {
* @type {ol.interaction.Draw.Mode_}
* @private
*/
this.mode_ = _ol_interaction_Draw_.getMode_(this.type_);
this.mode_ = Draw.getMode_(this.type_);
/**
* Stop click, singleclick, and doubleclick events from firing during drawing.
@@ -114,7 +114,7 @@ var _ol_interaction_Draw_ = function(options) {
*/
this.minPoints_ = options.minPoints ?
options.minPoints :
(this.mode_ === _ol_interaction_Draw_.Mode_.POLYGON ? 3 : 2);
(this.mode_ === Draw.Mode_.POLYGON ? 3 : 2);
/**
* The number of points that can be drawn before a polygon ring or line string
@@ -151,11 +151,11 @@ var _ol_interaction_Draw_ = function(options) {
} else {
var Constructor;
var mode = this.mode_;
if (mode === _ol_interaction_Draw_.Mode_.POINT) {
if (mode === Draw.Mode_.POINT) {
Constructor = Point;
} else if (mode === _ol_interaction_Draw_.Mode_.LINE_STRING) {
} else if (mode === Draw.Mode_.LINE_STRING) {
Constructor = LineString;
} else if (mode === _ol_interaction_Draw_.Mode_.POLYGON) {
} else if (mode === Draw.Mode_.POLYGON) {
Constructor = Polygon;
}
/**
@@ -167,7 +167,7 @@ var _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 === Draw.Mode_.POLYGON) {
if (coordinates[0].length) {
// Add a closing coordinate to match the first
geometry.setCoordinates([coordinates[0].concat([coordinates[0][0]])]);
@@ -255,7 +255,7 @@ var _ol_interaction_Draw_ = function(options) {
wrapX: options.wrapX ? options.wrapX : false
}),
style: options.style ? options.style :
_ol_interaction_Draw_.getDefaultStyleFunction()
Draw.getDefaultStyleFunction()
});
/**
@@ -290,13 +290,13 @@ var _ol_interaction_Draw_ = function(options) {
};
inherits(_ol_interaction_Draw_, _ol_interaction_Pointer_);
inherits(Draw, _ol_interaction_Pointer_);
/**
* @return {ol.StyleFunction} Styles.
*/
_ol_interaction_Draw_.getDefaultStyleFunction = function() {
Draw.getDefaultStyleFunction = function() {
var styles = _ol_style_Style_.createDefaultEditing();
return function(feature, resolution) {
return styles[feature.getGeometry().getType()];
@@ -307,7 +307,7 @@ _ol_interaction_Draw_.getDefaultStyleFunction = function() {
/**
* @inheritDoc
*/
_ol_interaction_Draw_.prototype.setMap = function(map) {
Draw.prototype.setMap = function(map) {
_ol_interaction_Pointer_.prototype.setMap.call(this, map);
this.updateState_();
};
@@ -321,8 +321,8 @@ _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);
Draw.handleEvent = function(event) {
this.freehand_ = this.mode_ !== Draw.Mode_.POINT && this.freehandCondition_(event);
var pass = true;
if (this.freehand_ &&
event.type === MapBrowserEventType.POINTERDRAG &&
@@ -347,7 +347,7 @@ _ol_interaction_Draw_.handleEvent = function(event) {
* @this {ol.interaction.Draw}
* @private
*/
_ol_interaction_Draw_.handleDownEvent_ = function(event) {
Draw.handleDownEvent_ = function(event) {
this.shouldHandle_ = !this.freehand_;
if (this.freehand_) {
@@ -371,17 +371,17 @@ _ol_interaction_Draw_.handleDownEvent_ = function(event) {
* @this {ol.interaction.Draw}
* @private
*/
_ol_interaction_Draw_.handleUpEvent_ = function(event) {
Draw.handleUpEvent_ = function(event) {
var pass = true;
this.handlePointerMove_(event);
var circleMode = this.mode_ === _ol_interaction_Draw_.Mode_.CIRCLE;
var circleMode = this.mode_ === Draw.Mode_.CIRCLE;
if (this.shouldHandle_) {
if (!this.finishCoordinate_) {
this.startDrawing_(event);
if (this.mode_ === _ol_interaction_Draw_.Mode_.POINT) {
if (this.mode_ === Draw.Mode_.POINT) {
this.finishDrawing();
}
} else if (this.freehand_ || circleMode) {
@@ -411,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) {
Draw.prototype.handlePointerMove_ = function(event) {
if (this.downPx_ &&
((!this.freehand_ && this.shouldHandle_) ||
(this.freehand_ && !this.shouldHandle_))) {
@@ -440,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) {
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_ === Draw.Mode_.LINE_STRING) {
potentiallyDone = this.sketchCoords_.length > this.minPoints_;
} else if (this.mode_ === _ol_interaction_Draw_.Mode_.POLYGON) {
} else if (this.mode_ === Draw.Mode_.POLYGON) {
potentiallyDone = this.sketchCoords_[0].length >
this.minPoints_;
potentiallyFinishCoordinates = [this.sketchCoords_[0][0],
@@ -478,7 +478,7 @@ _ol_interaction_Draw_.prototype.atFinish_ = function(event) {
* @param {ol.MapBrowserEvent} event Event.
* @private
*/
_ol_interaction_Draw_.prototype.createOrUpdateSketchPoint_ = function(event) {
Draw.prototype.createOrUpdateSketchPoint_ = function(event) {
var coordinates = event.coordinate.slice();
if (!this.sketchPoint_) {
this.sketchPoint_ = new _ol_Feature_(new Point(coordinates));
@@ -495,17 +495,17 @@ _ol_interaction_Draw_.prototype.createOrUpdateSketchPoint_ = function(event) {
* @param {ol.MapBrowserEvent} event Event.
* @private
*/
_ol_interaction_Draw_.prototype.startDrawing_ = function(event) {
Draw.prototype.startDrawing_ = function(event) {
var start = event.coordinate;
this.finishCoordinate_ = start;
if (this.mode_ === _ol_interaction_Draw_.Mode_.POINT) {
if (this.mode_ === Draw.Mode_.POINT) {
this.sketchCoords_ = start.slice();
} else if (this.mode_ === _ol_interaction_Draw_.Mode_.POLYGON) {
} else if (this.mode_ === 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_ === Draw.Mode_.CIRCLE) {
this.sketchLineCoords_ = this.sketchCoords_;
}
}
@@ -520,7 +520,7 @@ _ol_interaction_Draw_.prototype.startDrawing_ = function(event) {
}
this.sketchFeature_.setGeometry(geometry);
this.updateSketchFeatures_();
this.dispatchEvent(new _ol_interaction_Draw_.Event(
this.dispatchEvent(new Draw.Event(
_ol_interaction_DrawEventType_.DRAWSTART, this.sketchFeature_));
};
@@ -530,13 +530,13 @@ _ol_interaction_Draw_.prototype.startDrawing_ = function(event) {
* @param {ol.MapBrowserEvent} event Event.
* @private
*/
_ol_interaction_Draw_.prototype.modifyDrawing_ = function(event) {
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_ === Draw.Mode_.POINT) {
last = this.sketchCoords_;
} else if (this.mode_ === _ol_interaction_Draw_.Mode_.POLYGON) {
} else if (this.mode_ === Draw.Mode_.POLYGON) {
coordinates = this.sketchCoords_[0];
last = coordinates[coordinates.length - 1];
if (this.atFinish_(event)) {
@@ -556,7 +556,7 @@ _ol_interaction_Draw_.prototype.modifyDrawing_ = function(event) {
}
var sketchLineGeom;
if (geometry instanceof Polygon &&
this.mode_ !== _ol_interaction_Draw_.Mode_.POLYGON) {
this.mode_ !== Draw.Mode_.POLYGON) {
if (!this.sketchLine_) {
this.sketchLine_ = new _ol_Feature_(new LineString(null));
}
@@ -577,12 +577,12 @@ _ol_interaction_Draw_.prototype.modifyDrawing_ = function(event) {
* @param {ol.MapBrowserEvent} event Event.
* @private
*/
_ol_interaction_Draw_.prototype.addToDrawing_ = function(event) {
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_ === Draw.Mode_.LINE_STRING) {
this.finishCoordinate_ = coordinate.slice();
coordinates = this.sketchCoords_;
if (coordinates.length >= this.maxPoints_) {
@@ -594,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_ === Draw.Mode_.POLYGON) {
coordinates = this.sketchCoords_[0];
if (coordinates.length >= this.maxPoints_) {
if (this.freehand_) {
@@ -620,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() {
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_ === 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_ === Draw.Mode_.POLYGON) {
coordinates = this.sketchCoords_[0];
coordinates.splice(-2, 1);
sketchLineGeom = /** @type {ol.geom.LineString} */ (this.sketchLine_.getGeometry());
@@ -655,15 +655,15 @@ _ol_interaction_Draw_.prototype.removeLastPoint = function() {
* inserting the feature.
* @api
*/
_ol_interaction_Draw_.prototype.finishDrawing = function() {
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_ === 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_ === Draw.Mode_.POLYGON) {
// remove the redundant last point in ring
coordinates[0].pop();
this.geometryFunction_(coordinates, geometry);
@@ -680,7 +680,7 @@ _ol_interaction_Draw_.prototype.finishDrawing = function() {
}
// First dispatch event to allow full set up of feature
this.dispatchEvent(new _ol_interaction_Draw_.Event(
this.dispatchEvent(new Draw.Event(
_ol_interaction_DrawEventType_.DRAWEND, sketchFeature));
// Then insert feature
@@ -698,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() {
Draw.prototype.abortDrawing_ = function() {
this.finishCoordinate_ = null;
var sketchFeature = this.sketchFeature_;
if (sketchFeature) {
@@ -718,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) {
Draw.prototype.extend = function(feature) {
var geometry = feature.getGeometry();
var lineString = /** @type {ol.geom.LineString} */ (geometry);
this.sketchFeature_ = feature;
@@ -727,7 +727,7 @@ _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(
this.dispatchEvent(new Draw.Event(
_ol_interaction_DrawEventType_.DRAWSTART, this.sketchFeature_));
};
@@ -735,14 +735,14 @@ _ol_interaction_Draw_.prototype.extend = function(feature) {
/**
* @inheritDoc
*/
_ol_interaction_Draw_.prototype.shouldStopEvent = FALSE;
Draw.prototype.shouldStopEvent = FALSE;
/**
* Redraw the sketch features.
* @private
*/
_ol_interaction_Draw_.prototype.updateSketchFeatures_ = function() {
Draw.prototype.updateSketchFeatures_ = function() {
var sketchFeatures = [];
if (this.sketchFeature_) {
sketchFeatures.push(this.sketchFeature_);
@@ -762,7 +762,7 @@ _ol_interaction_Draw_.prototype.updateSketchFeatures_ = function() {
/**
* @private
*/
_ol_interaction_Draw_.prototype.updateState_ = function() {
Draw.prototype.updateState_ = function() {
var map = this.getMap();
var active = this.getActive();
if (!map || !active) {
@@ -785,7 +785,7 @@ _ol_interaction_Draw_.prototype.updateState_ = function() {
* polygon.
* @api
*/
_ol_interaction_Draw_.createRegularPolygon = function(opt_sides, opt_angle) {
Draw.createRegularPolygon = function(opt_sides, opt_angle) {
return (
/**
* @param {ol.Coordinate|Array.<ol.Coordinate>|Array.<Array.<ol.Coordinate>>} coordinates
@@ -815,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() {
Draw.createBox = function() {
return (
/**
* @param {Array.<ol.Coordinate>} coordinates
@@ -845,19 +845,19 @@ _ol_interaction_Draw_.createBox = function() {
* @return {ol.interaction.Draw.Mode_} Drawing mode.
* @private
*/
_ol_interaction_Draw_.getMode_ = function(type) {
Draw.getMode_ = function(type) {
var mode;
if (type === GeometryType.POINT ||
type === GeometryType.MULTI_POINT) {
mode = _ol_interaction_Draw_.Mode_.POINT;
mode = Draw.Mode_.POINT;
} else if (type === GeometryType.LINE_STRING ||
type === GeometryType.MULTI_LINE_STRING) {
mode = _ol_interaction_Draw_.Mode_.LINE_STRING;
mode = Draw.Mode_.LINE_STRING;
} else if (type === GeometryType.POLYGON ||
type === GeometryType.MULTI_POLYGON) {
mode = _ol_interaction_Draw_.Mode_.POLYGON;
mode = Draw.Mode_.POLYGON;
} else if (type === GeometryType.CIRCLE) {
mode = _ol_interaction_Draw_.Mode_.CIRCLE;
mode = Draw.Mode_.CIRCLE;
}
return /** @type {!ol.interaction.Draw.Mode_} */ (mode);
};
@@ -869,7 +869,7 @@ _ol_interaction_Draw_.getMode_ = function(type) {
* @enum {string}
* @private
*/
_ol_interaction_Draw_.Mode_ = {
Draw.Mode_ = {
POINT: 'Point',
LINE_STRING: 'LineString',
POLYGON: 'Polygon',
@@ -887,7 +887,7 @@ _ol_interaction_Draw_.Mode_ = {
* @param {ol.interaction.DrawEventType} type Type.
* @param {ol.Feature} feature The feature drawn.
*/
_ol_interaction_Draw_.Event = function(type, feature) {
Draw.Event = function(type, feature) {
Event.call(this, type);
@@ -899,5 +899,6 @@ _ol_interaction_Draw_.Event = function(type, feature) {
this.feature = feature;
};
inherits(_ol_interaction_Draw_.Event, Event);
export default _ol_interaction_Draw_;
inherits(Draw.Event, Event);
export default Draw;

View File

@@ -12,7 +12,7 @@ import MultiPoint from '../../../../src/ol/geom/MultiPoint.js';
import MultiPolygon from '../../../../src/ol/geom/MultiPolygon.js';
import Point from '../../../../src/ol/geom/Point.js';
import Polygon from '../../../../src/ol/geom/Polygon.js';
import _ol_interaction_Draw_ from '../../../../src/ol/interaction/Draw.js';
import Draw from '../../../../src/ol/interaction/Draw.js';
import Interaction from '../../../../src/ol/interaction/Interaction.js';
import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js';
import _ol_pointer_PointerEvent_ from '../../../../src/ol/pointer/PointerEvent.js';
@@ -79,16 +79,16 @@ describe('ol.interaction.Draw', function() {
describe('constructor', function() {
it('creates a new interaction', function() {
var draw = new _ol_interaction_Draw_({
var draw = new Draw({
source: source,
type: 'Point'
});
expect(draw).to.be.a(_ol_interaction_Draw_);
expect(draw).to.be.a(Draw);
expect(draw).to.be.a(Interaction);
});
it('accepts a freehand option', function() {
var draw = new _ol_interaction_Draw_({
var draw = new Draw({
source: source,
type: 'LineString',
freehand: true
@@ -108,7 +108,7 @@ describe('ol.interaction.Draw', function() {
describe('specifying a geometryName', function() {
beforeEach(function() {
var draw = new _ol_interaction_Draw_({
var draw = new Draw({
source: source,
geometryName: 'the_geom',
type: 'Point'
@@ -129,7 +129,7 @@ describe('ol.interaction.Draw', function() {
describe('specifying a clickTolerance', function() {
beforeEach(function() {
var draw = new _ol_interaction_Draw_({
var draw = new Draw({
source: source,
type: 'Point',
clickTolerance: 6
@@ -158,7 +158,7 @@ describe('ol.interaction.Draw', function() {
var draw;
beforeEach(function() {
draw = new _ol_interaction_Draw_({
draw = new Draw({
source: source,
type: 'Point'
});
@@ -236,7 +236,7 @@ describe('ol.interaction.Draw', function() {
describe('drawing multipoints', function() {
beforeEach(function() {
map.addInteraction(new _ol_interaction_Draw_({
map.addInteraction(new Draw({
source: source,
type: 'MultiPoint'
}));
@@ -259,7 +259,7 @@ describe('ol.interaction.Draw', function() {
var draw;
beforeEach(function() {
draw = new _ol_interaction_Draw_({
draw = new Draw({
source: source,
type: 'LineString'
});
@@ -427,7 +427,7 @@ describe('ol.interaction.Draw', function() {
describe('drawing with a finishCondition', function() {
beforeEach(function() {
var draw = new _ol_interaction_Draw_({
var draw = new Draw({
source: source,
type: 'LineString',
finishCondition: function(event) {
@@ -477,7 +477,7 @@ describe('ol.interaction.Draw', function() {
describe('drawing multi-linestrings', function() {
beforeEach(function() {
map.addInteraction(new _ol_interaction_Draw_({
map.addInteraction(new Draw({
source: source,
type: 'MultiLineString'
}));
@@ -511,7 +511,7 @@ describe('ol.interaction.Draw', function() {
var draw;
beforeEach(function() {
draw = new _ol_interaction_Draw_({
draw = new Draw({
source: source,
type: 'Polygon'
});
@@ -697,7 +697,7 @@ describe('ol.interaction.Draw', function() {
describe('drawing multi-polygons', function() {
beforeEach(function() {
map.addInteraction(new _ol_interaction_Draw_({
map.addInteraction(new Draw({
source: source,
type: 'MultiPolygon'
}));
@@ -774,7 +774,7 @@ describe('ol.interaction.Draw', function() {
var draw;
beforeEach(function() {
draw = new _ol_interaction_Draw_({
draw = new Draw({
source: source,
type: 'Circle'
});
@@ -846,7 +846,7 @@ describe('ol.interaction.Draw', function() {
var interaction;
beforeEach(function() {
interaction = new _ol_interaction_Draw_({
interaction = new Draw({
type: 'LineString'
});
@@ -915,7 +915,7 @@ describe('ol.interaction.Draw', function() {
var interaction;
beforeEach(function() {
interaction = new _ol_interaction_Draw_({
interaction = new Draw({
type: 'LineString'
});
expect(interaction.getActive()).to.be(true);
@@ -968,11 +968,11 @@ describe('ol.interaction.Draw', function() {
describe('ol.interaction.Draw.createRegularPolygon', function() {
it('creates a regular polygon in Circle mode', function() {
var draw = new _ol_interaction_Draw_({
var draw = new Draw({
source: source,
type: 'Circle',
geometryFunction:
_ol_interaction_Draw_.createRegularPolygon(4, Math.PI / 4)
Draw.createRegularPolygon(4, Math.PI / 4)
});
map.addInteraction(draw);
@@ -998,10 +998,10 @@ describe('ol.interaction.Draw', function() {
describe('ol.interaction.Draw.createBox', function() {
it('creates a box-shaped polygon in Circle mode', function() {
var draw = new _ol_interaction_Draw_({
var draw = new Draw({
source: source,
type: 'Circle',
geometryFunction: _ol_interaction_Draw_.createBox()
geometryFunction: Draw.createBox()
});
map.addInteraction(draw);
@@ -1030,7 +1030,7 @@ describe('ol.interaction.Draw', function() {
var feature;
beforeEach(function() {
draw = new _ol_interaction_Draw_({
draw = new Draw({
source: source,
type: 'LineString'
});