diff --git a/dist/bundle.es.js b/dist/bundle.es.js deleted file mode 100644 index d560458..0000000 --- a/dist/bundle.es.js +++ /dev/null @@ -1,1035 +0,0 @@ -/*! -Rotate vector features interaction for OpenLayers - -@package ol-rotate-feature -@author Vladimir Vershinin -@version 1.3.0 -@licence MIT -@copyright (c) 2016-2018, Vladimir Vershinin -*/ -import PointerInteraction from 'ol/interaction/pointer'; -import Collection from 'ol/collection'; -import VectorLayer from 'ol/layer/vector'; -import VectorSource from 'ol/source/vector'; -import Feature from 'ol/feature'; -import Point from 'ol/geom/point'; -import Polygon from 'ol/geom/polygon'; -import GeometryCollection from 'ol/geom/geometrycollection'; -import Style from 'ol/style/style'; -import RegularShape from 'ol/style/regularshape'; -import Stroke from 'ol/style/stroke'; -import Fill from 'ol/style/fill'; -import Text from 'ol/style/text'; -import extentHelper from 'ol/extent'; - -/** - * @param {boolean} condition - * @param {string} message - * @throws Error - */ -function assert(condition) { - var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; - - message = ['Assertion failed', message].join(': '); - - if (!condition) { - throw new Error(message); - } -} - -/** - * @param {*} arg - * @returns {*} - */ -function identity(arg) { - return arg; -} - -/** - * @param {...*} args - * @return {*} - */ - - -/** - * @param {string} [prefix] - * @return {number} - */ - - -function includes(arr, value) { - return arr.indexOf(value) !== -1; -} - -function isArray(val) { - return Object.prototype.toString.call(val) === '[object Array]'; -} - -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { - return typeof obj; -} : function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; -}; - - - - - - - - - - - -var classCallCheck = function (instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } -}; - -var createClass = function () { - function defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); - } - } - - return function (Constructor, protoProps, staticProps) { - if (protoProps) defineProperties(Constructor.prototype, protoProps); - if (staticProps) defineProperties(Constructor, staticProps); - return Constructor; - }; -}(); - - - - - -var defineProperty = function (obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - - return obj; -}; - -var get = function get(object, property, receiver) { - if (object === null) object = Function.prototype; - var desc = Object.getOwnPropertyDescriptor(object, property); - - if (desc === undefined) { - var parent = Object.getPrototypeOf(object); - - if (parent === null) { - return undefined; - } else { - return get(parent, property, receiver); - } - } else if ("value" in desc) { - return desc.value; - } else { - var getter = desc.get; - - if (getter === undefined) { - return undefined; - } - - return getter.call(receiver); - } -}; - -var inherits = function (subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); - } - - subClass.prototype = Object.create(superClass && superClass.prototype, { - constructor: { - value: subClass, - enumerable: false, - writable: true, - configurable: true - } - }); - if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; -}; - - - - - - - - - - - -var possibleConstructorReturn = function (self, call) { - if (!self) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - - return call && (typeof call === "object" || typeof call === "function") ? call : self; -}; - -/** - * @enum {string} - */ -var RotateFeatureEventType = { - /** - * Triggered upon feature rotate start. - * @event RotateFeatureEvent#rotatestart - */ - START: 'rotatestart', - /** - * Triggered upon feature rotation. - * @event RotateFeatureEvent#rotating - */ - ROTATING: 'rotating', - /** - * Triggered upon feature rotation end. - * @event RotateFeatureEvent#rotateend - */ - END: 'rotateend' - - /** - * Events emitted by RotateFeatureInteraction instances are instances of this type. - * - * @class - * @author Vladimir Vershinin - */ -}; -var RotateFeatureEvent = function () { - /** - * @param {string} type Type. - * @param {ol.Collection} features Rotated features. - * @param {number} angle Angle in radians. - * @param {ol.Coordinate} anchor Anchor position. - */ - function RotateFeatureEvent(type, features, angle, anchor) { - classCallCheck(this, RotateFeatureEvent); - - /** - * @type {boolean} - * @private - */ - this.propagationStopped_ = false; - - /** - * The event type. - * @type {string} - * @private - */ - this.type_ = type; - - /** - * The features being rotated. - * @type {ol.Collection} - * @private - */ - this.features_ = features; - /** - * Current angle in radians. - * @type {number} - * @private - */ - this.angle_ = angle; - /** - * Current rotation anchor. - * @type {ol.Coordinate} - * @private - */ - this.anchor_ = anchor; - } - - /** - * @type {boolean} - */ - - - createClass(RotateFeatureEvent, [{ - key: 'preventDefault', - - - /** - * Prevent event propagation. - */ - value: function preventDefault() { - this.propagationStopped_ = true; - } - - /** - * Stop event propagation. - */ - - }, { - key: 'stopPropagation', - value: function stopPropagation() { - this.propagationStopped_ = true; - } - }, { - key: 'propagationStopped', - get: function get$$1() { - return this.propagationStopped_; - } - - /** - * @type {RotateFeatureEventType} - */ - - }, { - key: 'type', - get: function get$$1() { - return this.type_; - } - - /** - * @type {ol.Collection} - */ - - }, { - key: 'features', - get: function get$$1() { - return this.features_; - } - - /** - * @type {number} - */ - - }, { - key: 'angle', - get: function get$$1() { - return this.angle_; - } - - /** - * @type {ol.Coordinate} - */ - - }, { - key: 'anchor', - get: function get$$1() { - return this.anchor_; - } - }]); - return RotateFeatureEvent; -}(); - -/** - * Rotate interaction class. - * Adds controls to rotate vector features. - * Writes out total angle in radians (positive is counter-clockwise) to property for each feature. - */ -var ANCHOR_KEY = 'rotate-anchor'; -var ARROW_KEY = 'rotate-arrow'; - -var ANGLE_PROP = 'angle'; -var ANCHOR_PROP = 'anchor'; - -/** - * @todo todo добавить опцию condition - для возможности переопределения клавиш - */ - -var RotateFeatureInteraction = function (_PointerInteraction) { - inherits(RotateFeatureInteraction, _PointerInteraction); - - /** - * @param {InteractionOptions} options - */ - function RotateFeatureInteraction() { - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - classCallCheck(this, RotateFeatureInteraction); - - /** - * @type {string} - * @private - */ - var _this = possibleConstructorReturn(this, (RotateFeatureInteraction.__proto__ || Object.getPrototypeOf(RotateFeatureInteraction)).call(this, { - handleEvent: handleEvent, - handleDownEvent: handleDownEvent, - handleUpEvent: handleUpEvent, - handleDragEvent: handleDragEvent, - handleMoveEvent: handleMoveEvent - })); - - _this.previousCursor_ = undefined; - /** - * @type {ol.Feature} - * @private - */ - _this.anchorFeature_ = undefined; - /** - * @type {ol.Feature} - * @private - */ - _this.arrowFeature_ = undefined; - /** - * @type {ol.Coordinate} - * @private - */ - _this.lastCoordinate_ = undefined; - /** - * @type {boolean} - * @private - */ - _this.anchorMoving_ = false; - /** - * @type {ol.layer.Vector} - * @private - */ - _this.overlay_ = new VectorLayer({ - style: options.style || getDefaultStyle(), - source: new VectorSource({ - features: new Collection() - }) - }); - /** - * @type {ol.Collection} - * @private - */ - _this.features_ = undefined; - if (options.features) { - if (isArray(options.features)) { - _this.features_ = new Collection(options.features); - } else if (options.features instanceof Collection) { - _this.features_ = options.features; - } else { - throw new Error('Features option should be an array or collection of features, ' + 'got ' + _typeof(options.features)); - } - } else { - _this.features_ = new Collection(); - } - - _this.setAnchor(options.anchor || getFeaturesCentroid(_this.features_)); - _this.setAngle(options.angle || 0); - - _this.features_.on('add', _this.onFeatureAdd_.bind(_this)); - _this.features_.on('remove', _this.onFeatureRemove_.bind(_this)); - _this.on('change:' + ANGLE_PROP, _this.onAngleChange_.bind(_this)); - _this.on('change:' + ANCHOR_PROP, _this.onAnchorChange_.bind(_this)); - - _this.createOrUpdateAnchorFeature_(); - _this.createOrUpdateArrowFeature_(); - return _this; - } - - /** - * @type {ol.Collection} - */ - - - createClass(RotateFeatureInteraction, [{ - key: 'setMap', - - - /** - * @param {ol.Map} map - */ - value: function setMap(map) { - this.overlay_.setMap(map); - get(RotateFeatureInteraction.prototype.__proto__ || Object.getPrototypeOf(RotateFeatureInteraction.prototype), 'setMap', this).call(this, map); - } - - /** - * @param {boolean} active - */ - - }, { - key: 'setActive', - value: function setActive(active) { - if (this.overlay_) { - this.overlay_.setMap(active ? this.map : undefined); - } - - get(RotateFeatureInteraction.prototype.__proto__ || Object.getPrototypeOf(RotateFeatureInteraction.prototype), 'setActive', this).call(this, active); - } - - /** - * Set current angle of interaction features. - * - * @param {number} angle - */ - - }, { - key: 'setAngle', - value: function setAngle(angle) { - assert(!isNaN(parseFloat(angle)), 'Numeric value passed'); - - this.set(ANGLE_PROP, parseFloat(angle)); - } - - /** - * Returns current angle of interaction features. - * - * @return {number} - */ - - }, { - key: 'getAngle', - value: function getAngle() { - return this.get(ANGLE_PROP); - } - - /** - * Set current anchor position. - * - * @param {ol.Coordinate | undefined} anchor - */ - - }, { - key: 'setAnchor', - value: function setAnchor(anchor) { - assert(anchor == null || isArray(anchor) && anchor.length === 2, 'Array of two elements passed'); - - this.set(ANCHOR_PROP, anchor != null ? anchor.map(parseFloat) : getFeaturesCentroid(this.features_)); - } - - /** - * Returns current anchor position. - * - * @return {ol.Coordinate | undefined} - */ - - }, { - key: 'getAnchor', - value: function getAnchor() { - return this.get(ANCHOR_PROP); - } - - /** - * @private - */ - - }, { - key: 'createOrUpdateAnchorFeature_', - value: function createOrUpdateAnchorFeature_() { - var angle = this.getAngle(); - var anchor = this.getAnchor(); - - if (!anchor) return; - - if (this.anchorFeature_) { - this.anchorFeature_.getGeometry().setCoordinates(anchor); - this.anchorFeature_.set(ANGLE_PROP, angle); - } else { - var _ref; - - this.anchorFeature_ = new Feature((_ref = { - geometry: new Point(anchor) - }, defineProperty(_ref, ANGLE_PROP, angle), defineProperty(_ref, ANCHOR_KEY, true), _ref)); - this.overlay_.getSource().addFeature(this.anchorFeature_); - } - } - - /** - * @private - */ - - }, { - key: 'createOrUpdateArrowFeature_', - value: function createOrUpdateArrowFeature_() { - var angle = this.getAngle(); - var anchor = this.getAnchor(); - - if (!anchor) return; - - if (this.arrowFeature_) { - this.arrowFeature_.getGeometry().setCoordinates(anchor); - this.arrowFeature_.set(ANGLE_PROP, angle); - } else { - var _ref2; - - this.arrowFeature_ = new Feature((_ref2 = { - geometry: new Point(anchor) - }, defineProperty(_ref2, ANGLE_PROP, angle), defineProperty(_ref2, ARROW_KEY, true), _ref2)); - this.overlay_.getSource().addFeature(this.arrowFeature_); - } - } - - /** - * @private - */ - - }, { - key: 'resetAngleAndAnchor_', - value: function resetAngleAndAnchor_() { - this.resetAngle_(); - this.resetAnchor_(); - } - - /** - * @private - */ - - }, { - key: 'resetAngle_', - value: function resetAngle_() { - this.set(ANGLE_PROP, 0, true); - this.arrowFeature_ && this.arrowFeature_.set(ANGLE_PROP, this.getAngle()); - this.anchorFeature_ && this.anchorFeature_.set(ANGLE_PROP, this.getAngle()); - } - - /** - * @private - */ - - }, { - key: 'resetAnchor_', - value: function resetAnchor_() { - this.set(ANCHOR_PROP, getFeaturesCentroid(this.features_), true); - - if (this.getAnchor()) { - this.arrowFeature_ && this.arrowFeature_.getGeometry().setCoordinates(this.getAnchor()); - this.anchorFeature_ && this.anchorFeature_.getGeometry().setCoordinates(this.getAnchor()); - } - } - - /** - * @private - */ - - }, { - key: 'onFeatureAdd_', - value: function onFeatureAdd_() { - this.resetAngleAndAnchor_(); - this.createOrUpdateAnchorFeature_(); - this.createOrUpdateArrowFeature_(); - } - - /** - * @private - */ - - }, { - key: 'onFeatureRemove_', - value: function onFeatureRemove_() { - this.resetAngleAndAnchor_(); - - if (this.features_.getLength()) { - this.createOrUpdateAnchorFeature_(); - this.createOrUpdateArrowFeature_(); - } else { - this.overlay_.getSource().clear(); - this.anchorFeature_ = this.arrowFeature_ = undefined; - } - } - - /** - * @private - */ - - }, { - key: 'onAngleChange_', - value: function onAngleChange_(_ref3) { - var _this2 = this; - - var oldValue = _ref3.oldValue; - - this.features_.forEach(function (feature) { - return feature.getGeometry().rotate(_this2.getAngle() - oldValue, _this2.getAnchor()); - }); - this.arrowFeature_ && this.arrowFeature_.set(ANGLE_PROP, this.getAngle()); - this.anchorFeature_ && this.anchorFeature_.set(ANGLE_PROP, this.getAngle()); - } - - /** - * @private - */ - - }, { - key: 'onAnchorChange_', - value: function onAnchorChange_() { - var anchor = this.getAnchor(); - - if (anchor) { - this.anchorFeature_ && this.anchorFeature_.getGeometry().setCoordinates(anchor); - this.arrowFeature_ && this.arrowFeature_.getGeometry().setCoordinates(anchor); - } - } - - /** - * @param {ol.Collection} features - * @private - */ - - }, { - key: 'dispatchRotateStartEvent_', - value: function dispatchRotateStartEvent_(features) { - this.dispatchEvent(new RotateFeatureEvent(RotateFeatureEventType.START, features, this.getAngle(), this.getAnchor())); - } - - /** - * @param {ol.Collection} features - * @private - */ - - }, { - key: 'dispatchRotatingEvent_', - value: function dispatchRotatingEvent_(features) { - this.dispatchEvent(new RotateFeatureEvent(RotateFeatureEventType.ROTATING, features, this.getAngle(), this.getAnchor())); - } - - /** - * @param {ol.Collection} features - * @private - */ - - }, { - key: 'dispatchRotateEndEvent_', - value: function dispatchRotateEndEvent_(features) { - this.dispatchEvent(new RotateFeatureEvent(RotateFeatureEventType.END, features, this.getAngle(), this.getAnchor())); - } - }, { - key: 'features', - get: function get$$1() { - return this.features_; - } - - /** - * @type {number} - */ - - }, { - key: 'angle', - get: function get$$1() { - return this.getAngle(); - } - - /** - * @param {number} angle - */ - , - set: function set$$1(angle) { - this.setAngle(angle); - } - - /** - * @type {ol.Coordinate|undefined} - */ - - }, { - key: 'anchor', - get: function get$$1() { - return this.getAnchor(); - } - - /** - * @param {ol.Coordinate|undefined} anchor - */ - , - set: function set$$1(anchor) { - this.setAnchor(anchor); - } - - /** - * @param {ol.Map} map - */ - - }, { - key: 'map', - set: function set$$1(map) { - this.setMap(map); - } - - /** - * @type {ol.Map} - */ - , - get: function get$$1() { - return this.getMap(); - } - - /** - * @param {boolean} active - */ - - }, { - key: 'active', - set: function set$$1(active) { - this.setActive(active); - } - - /** - * @type {boolean} - */ - , - get: function get$$1() { - return this.getActive(); - } - }]); - return RotateFeatureInteraction; -}(PointerInteraction); - -function handleEvent(evt) { - // disable selection of inner features - var foundFeature = evt.map.forEachFeatureAtPixel(evt.pixel, identity); - if (includes(['click', 'singleclick', 'dblclick'], evt.type) && includes([this.anchorFeature_, this.arrowFeature_], foundFeature)) { - return false; - } - - return PointerInteraction.handleEvent.call(this, evt); -} - -/** - * @param {ol.MapBrowserEvent} evt Event. - * @return {boolean} - * @this {RotateFeatureInteraction} - * @private - */ -function handleDownEvent(evt) { - var foundFeature = evt.map.forEachFeatureAtPixel(evt.pixel, identity); - - // handle click & drag on features for rotation - if (foundFeature && !this.lastCoordinate_ && (includes(this.features_.getArray(), foundFeature) || foundFeature === this.arrowFeature_)) { - this.lastCoordinate_ = evt.coordinate; - - handleMoveEvent.call(this, evt); - this.dispatchRotateStartEvent_(this.features_); - - return true; - } - // handle click & drag on rotation anchor feature - else if (foundFeature && foundFeature === this.anchorFeature_) { - this.anchorMoving_ = true; - handleMoveEvent.call(this, evt); - - return true; - } - - return false; -} - -/** - * @param {ol.MapBrowserEvent} evt Event. - * @return {boolean} - * @this {RotateFeatureInteraction} - * @private - */ -function handleUpEvent(evt) { - // stop drag sequence of features - if (this.lastCoordinate_) { - this.lastCoordinate_ = undefined; - - handleMoveEvent.call(this, evt); - this.dispatchRotateEndEvent_(this.features_); - - return true; - } - // stop drag sequence of the anchors - else if (this.anchorMoving_) { - this.anchorMoving_ = false; - handleMoveEvent.call(this, evt); - - return true; - } - - return false; -} - -/** - * @param {ol.MapBrowserEvent} evt Event. - * @return {boolean} - * @this {RotateFeatureInteraction} - * @private - */ -function handleDragEvent(_ref4) { - var coordinate = _ref4.coordinate; - - var anchorCoordinate = this.anchorFeature_.getGeometry().getCoordinates(); - - // handle drag of features by angle - if (this.lastCoordinate_) { - // calculate vectors of last and current pointer positions - var lastVector = [this.lastCoordinate_[0] - anchorCoordinate[0], this.lastCoordinate_[1] - anchorCoordinate[1]]; - var newVector = [coordinate[0] - anchorCoordinate[0], coordinate[1] - anchorCoordinate[1]]; - - // calculate angle between last and current vectors (positive angle counter-clockwise) - var angle = Math.atan2(lastVector[0] * newVector[1] - newVector[0] * lastVector[1], lastVector[0] * newVector[0] + lastVector[1] * newVector[1]); - - this.setAngle(this.getAngle() + angle); - this.dispatchRotatingEvent_(this.features_); - - this.lastCoordinate_ = coordinate; - } - // handle drag of the anchor - else if (this.anchorMoving_) { - this.setAnchor(coordinate); - } -} - -/** - * @param {ol.MapBrowserEvent} evt Event. - * @return {boolean} - * @this {RotateFeatureInteraction} - * @private - */ -function handleMoveEvent(_ref5) { - var map = _ref5.map, - pixel = _ref5.pixel; - - var elem = map.getTargetElement(); - var foundFeature = map.forEachFeatureAtPixel(pixel, identity); - - var setCursor = function setCursor(cursor) { - var vendor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - - if (vendor) { - elem.style.cursor = '-webkit-' + cursor; - elem.style.cursor = '-moz-' + cursor; - } - - elem.style.cursor = cursor; - }; - - if (this.lastCoordinate_) { - this.previousCursor_ = elem.style.cursor; - setCursor('grabbing', true); - } else if (foundFeature && (includes(this.features_.getArray(), foundFeature) || foundFeature === this.arrowFeature_)) { - this.previousCursor_ = elem.style.cursor; - setCursor('grab', true); - } else if (foundFeature && foundFeature === this.anchorFeature_ || this.anchorMoving_) { - this.previousCursor_ = elem.style.cursor; - setCursor('crosshair'); - } else { - setCursor(this.previousCursor_ || ''); - this.previousCursor_ = undefined; - } -} - -/** - * @returns {StyleFunction} - * @private - */ -function getDefaultStyle() { - var _styles; - - var white = [255, 255, 255, 0.8]; - var blue = [0, 153, 255, 0.8]; - var transparent = [255, 255, 255, 0.01]; - var width = 2; - - var styles = (_styles = {}, defineProperty(_styles, ANCHOR_KEY, [new Style({ - image: new RegularShape({ - fill: new Fill({ - color: [0, 153, 255, 0.8] - }), - stroke: new Stroke({ - color: blue, - width: 1 - }), - radius: 4, - points: 6 - }), - zIndex: Infinity - })]), defineProperty(_styles, ARROW_KEY, [new Style({ - fill: new Fill({ - color: transparent - }), - stroke: new Stroke({ - color: white, - width: width + 2 - }), - text: new Text({ - font: '12px sans-serif', - offsetX: 20, - offsetY: -20, - fill: new Fill({ - color: 'blue' - }), - stroke: new Stroke({ - color: white, - width: width + 1 - }) - }), - zIndex: Infinity - }), new Style({ - fill: new Fill({ - color: transparent - }), - stroke: new Stroke({ - color: blue, - width: width - }), - zIndex: Infinity - })]), _styles); - - return function (feature, resolution) { - var style = void 0; - var angle = feature.get(ANGLE_PROP) || 0; - - switch (true) { - case feature.get(ANCHOR_KEY): - style = styles[ANCHOR_KEY]; - style[0].getImage().setRotation(-angle); - - return style; - case feature.get(ARROW_KEY): - style = styles[ARROW_KEY]; - - var coordinates = feature.getGeometry().getCoordinates(); - // generate arrow polygon - var geom = new Polygon([[[coordinates[0], coordinates[1] - 6 * resolution], [coordinates[0] + 8 * resolution, coordinates[1] - 12 * resolution], [coordinates[0], coordinates[1] + 30 * resolution], [coordinates[0] - 8 * resolution, coordinates[1] - 12 * resolution], [coordinates[0], coordinates[1] - 6 * resolution]]]); - - // and rotate it according to current angle - geom.rotate(angle, coordinates); - style[0].setGeometry(geom); - style[1].setGeometry(geom); - style[0].getText().setText(Math.round(-angle * 180 / Math.PI) + '°'); - - return style; - } - }; -} - -/** - * @param {ol.Collection|Array} features - * @returns {ol.Extent | undefined} - * @private - */ -function getFeaturesExtent(features) { - features = features instanceof Collection ? features.getArray() : features; - if (!features.length) return; - - return new GeometryCollection(features.map(function (feature) { - return feature.getGeometry(); - })).getExtent(); -} - -/** - * @param {ol.Collection | Array} features - * @return {ol.Coordinate | undefined} - */ -function getFeaturesCentroid(features) { - features = features instanceof Collection ? features.getArray() : features; - if (!features.length) return; - - return extentHelper.getCenter(getFeaturesExtent(features)); -} - -/** - * Rotate interaction for OpenLayers. - * Allows vector feature rotation. - * - * @author Vladimir Vershinin - * @licence MIT https://opensource.org/licenses/MIT - * @copyright (c) 2016-2017, Vladimir Vershinin - */ -// for backward compatibility -if (typeof window !== 'undefined' && window.ol) { - window.ol.interaction.RotateFeature = RotateFeatureInteraction; -} - -export default RotateFeatureInteraction; -//# sourceMappingURL=bundle.es.js.map diff --git a/dist/bundle.es.js.map b/dist/bundle.es.js.map deleted file mode 100644 index c104a83..0000000 --- a/dist/bundle.es.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"bundle.es.js","sources":["../src/util.js","../src/event.js","../src/interaction.js","../src/index.js"],"sourcesContent":["/**\n * @param {boolean} condition\n * @param {string} message\n * @throws Error\n */\nexport function assert (condition, message = '') {\n message = [ 'Assertion failed', message ].join(': ')\n\n if (!condition) {\n throw new Error(message)\n }\n}\n\n/**\n * @param {*} arg\n * @returns {*}\n */\nexport function identity (arg) {\n return arg\n}\n\n/**\n * @param {...*} args\n * @return {*}\n */\nexport function coalesce (...args) {\n return args.filter(value => value != null).shift()\n}\n\nconst counters = {}\n/**\n * @param {string} [prefix]\n * @return {number}\n */\nexport function uniqId (prefix = '') {\n const ns = prefix || 'default'\n counters[ ns ] = counters[ ns ] == null ? 0 : counters[ ns ]\n\n return String(prefix) + (++counters[ ns ])\n}\n\nexport function includes (arr, value) {\n return arr.indexOf(value) !== -1\n}\n\nexport function isArray (val) {\n return val::Object.prototype.toString() === '[object Array]'\n}\n","/**\n * @enum {string}\n */\nexport const RotateFeatureEventType = {\n /**\n * Triggered upon feature rotate start.\n * @event RotateFeatureEvent#rotatestart\n */\n START: 'rotatestart',\n /**\n * Triggered upon feature rotation.\n * @event RotateFeatureEvent#rotating\n */\n ROTATING: 'rotating',\n /**\n * Triggered upon feature rotation end.\n * @event RotateFeatureEvent#rotateend\n */\n END: 'rotateend'\n}\n\n/**\n * Events emitted by RotateFeatureInteraction instances are instances of this type.\n *\n * @class\n * @author Vladimir Vershinin\n */\nexport default class RotateFeatureEvent {\n /**\n * @param {string} type Type.\n * @param {ol.Collection} features Rotated features.\n * @param {number} angle Angle in radians.\n * @param {ol.Coordinate} anchor Anchor position.\n */\n constructor (type, features, angle, anchor) {\n /**\n * @type {boolean}\n * @private\n */\n this.propagationStopped_ = false\n\n /**\n * The event type.\n * @type {string}\n * @private\n */\n this.type_ = type\n\n /**\n * The features being rotated.\n * @type {ol.Collection}\n * @private\n */\n this.features_ = features\n /**\n * Current angle in radians.\n * @type {number}\n * @private\n */\n this.angle_ = angle\n /**\n * Current rotation anchor.\n * @type {ol.Coordinate}\n * @private\n */\n this.anchor_ = anchor\n }\n\n /**\n * @type {boolean}\n */\n get propagationStopped () {\n return this.propagationStopped_\n }\n\n /**\n * @type {RotateFeatureEventType}\n */\n get type () {\n return this.type_\n }\n\n /**\n * @type {ol.Collection}\n */\n get features () {\n return this.features_\n }\n\n /**\n * @type {number}\n */\n get angle () {\n return this.angle_\n }\n\n /**\n * @type {ol.Coordinate}\n */\n get anchor () {\n return this.anchor_\n }\n\n /**\n * Prevent event propagation.\n */\n preventDefault () {\n this.propagationStopped_ = true\n }\n\n /**\n * Stop event propagation.\n */\n stopPropagation () {\n this.propagationStopped_ = true\n }\n}\n","/**\n * Rotate interaction class.\n * Adds controls to rotate vector features.\n * Writes out total angle in radians (positive is counter-clockwise) to property for each feature.\n */\nimport PointerInteraction from 'ol/interaction/pointer'\nimport Collection from 'ol/collection'\nimport VectorLayer from 'ol/layer/vector'\nimport VectorSource from 'ol/source/vector'\nimport Feature from 'ol/feature'\nimport Point from 'ol/geom/point'\nimport Polygon from 'ol/geom/polygon'\nimport GeometryCollection from 'ol/geom/geometrycollection'\nimport Style from 'ol/style/style'\nimport RegularShape from 'ol/style/regularshape'\nimport Stroke from 'ol/style/stroke'\nimport Fill from 'ol/style/fill'\nimport Text from 'ol/style/text'\nimport extentHelper from 'ol/extent'\nimport { assert, identity, includes, isArray } from './util'\nimport RotateFeatureEvent, { RotateFeatureEventType } from './event'\n\nconst ANCHOR_KEY = 'rotate-anchor'\nconst ARROW_KEY = 'rotate-arrow'\n\nconst ANGLE_PROP = 'angle'\nconst ANCHOR_PROP = 'anchor'\n\n/**\n * @todo todo добавить опцию condition - для возможности переопределения клавиш\n */\nexport default class RotateFeatureInteraction extends PointerInteraction {\n /**\n * @param {InteractionOptions} options\n */\n constructor (options = {}) {\n super({\n handleEvent: handleEvent,\n handleDownEvent: handleDownEvent,\n handleUpEvent: handleUpEvent,\n handleDragEvent: handleDragEvent,\n handleMoveEvent: handleMoveEvent\n })\n /**\n * @type {string}\n * @private\n */\n this.previousCursor_ = undefined\n /**\n * @type {ol.Feature}\n * @private\n */\n this.anchorFeature_ = undefined\n /**\n * @type {ol.Feature}\n * @private\n */\n this.arrowFeature_ = undefined\n /**\n * @type {ol.Coordinate}\n * @private\n */\n this.lastCoordinate_ = undefined\n /**\n * @type {boolean}\n * @private\n */\n this.anchorMoving_ = false\n /**\n * @type {ol.layer.Vector}\n * @private\n */\n this.overlay_ = new VectorLayer({\n style: options.style || getDefaultStyle(),\n source: new VectorSource({\n features: new Collection()\n })\n })\n /**\n * @type {ol.Collection}\n * @private\n */\n this.features_ = undefined\n if (options.features) {\n if (isArray(options.features)) {\n this.features_ = new Collection(options.features)\n } else if (options.features instanceof Collection) {\n this.features_ = options.features\n } else {\n throw new Error('Features option should be an array or collection of features, ' +\n 'got ' + (typeof options.features))\n }\n } else {\n this.features_ = new Collection()\n }\n\n this.setAnchor(options.anchor || getFeaturesCentroid(this.features_))\n this.setAngle(options.angle || 0)\n\n this.features_.on('add', ::this.onFeatureAdd_)\n this.features_.on('remove', ::this.onFeatureRemove_)\n this.on('change:' + ANGLE_PROP, ::this.onAngleChange_)\n this.on('change:' + ANCHOR_PROP, ::this.onAnchorChange_)\n\n this.createOrUpdateAnchorFeature_()\n this.createOrUpdateArrowFeature_()\n }\n\n /**\n * @type {ol.Collection}\n */\n get features () {\n return this.features_\n }\n\n /**\n * @type {number}\n */\n get angle () {\n return this.getAngle()\n }\n\n /**\n * @param {number} angle\n */\n set angle (angle) {\n this.setAngle(angle)\n }\n\n /**\n * @type {ol.Coordinate|undefined}\n */\n get anchor () {\n return this.getAnchor()\n }\n\n /**\n * @param {ol.Coordinate|undefined} anchor\n */\n set anchor (anchor) {\n this.setAnchor(anchor)\n }\n\n /**\n * @param {ol.Map} map\n */\n set map (map) {\n this.setMap(map)\n }\n\n /**\n * @type {ol.Map}\n */\n get map() {\n return this.getMap()\n }\n\n /**\n * @param {boolean} active\n */\n set active (active) {\n this.setActive(active)\n }\n\n /**\n * @type {boolean}\n */\n get active () {\n return this.getActive()\n }\n\n /**\n * @param {ol.Map} map\n */\n setMap (map) {\n this.overlay_.setMap(map)\n super.setMap(map)\n }\n\n /**\n * @param {boolean} active\n */\n setActive (active) {\n if (this.overlay_) {\n this.overlay_.setMap(active ? this.map : undefined)\n }\n\n super.setActive(active)\n }\n\n /**\n * Set current angle of interaction features.\n *\n * @param {number} angle\n */\n setAngle (angle) {\n assert(!isNaN(parseFloat(angle)), 'Numeric value passed')\n\n this.set(ANGLE_PROP, parseFloat(angle))\n }\n\n /**\n * Returns current angle of interaction features.\n *\n * @return {number}\n */\n getAngle () {\n return this.get(ANGLE_PROP)\n }\n\n /**\n * Set current anchor position.\n *\n * @param {ol.Coordinate | undefined} anchor\n */\n setAnchor (anchor) {\n assert(anchor == null || isArray(anchor) && anchor.length === 2, 'Array of two elements passed')\n\n this.set(ANCHOR_PROP, anchor != null ? anchor.map(parseFloat) : getFeaturesCentroid(this.features_))\n }\n\n /**\n * Returns current anchor position.\n *\n * @return {ol.Coordinate | undefined}\n */\n getAnchor () {\n return this.get(ANCHOR_PROP)\n }\n\n /**\n * @private\n */\n createOrUpdateAnchorFeature_ () {\n const angle = this.getAngle()\n const anchor = this.getAnchor()\n\n if (!anchor) return\n\n if (this.anchorFeature_) {\n this.anchorFeature_.getGeometry().setCoordinates(anchor)\n this.anchorFeature_.set(ANGLE_PROP, angle)\n } else {\n this.anchorFeature_ = new Feature({\n geometry: new Point(anchor),\n [ ANGLE_PROP ]: angle,\n [ ANCHOR_KEY ]: true\n })\n this.overlay_.getSource().addFeature(this.anchorFeature_)\n }\n }\n\n /**\n * @private\n */\n createOrUpdateArrowFeature_ () {\n const angle = this.getAngle()\n const anchor = this.getAnchor()\n\n if (!anchor) return\n\n if (this.arrowFeature_) {\n this.arrowFeature_.getGeometry().setCoordinates(anchor)\n this.arrowFeature_.set(ANGLE_PROP, angle)\n } else {\n this.arrowFeature_ = new Feature({\n geometry: new Point(anchor),\n [ ANGLE_PROP ]: angle,\n [ ARROW_KEY ]: true\n })\n this.overlay_.getSource().addFeature(this.arrowFeature_)\n }\n }\n\n /**\n * @private\n */\n resetAngleAndAnchor_() {\n this.resetAngle_();\n this.resetAnchor_();\n }\n\n /**\n * @private\n */\n resetAngle_() {\n this.set(ANGLE_PROP, 0, true);\n this.arrowFeature_ && this.arrowFeature_.set(ANGLE_PROP, this.getAngle());\n this.anchorFeature_ && this.anchorFeature_.set(ANGLE_PROP, this.getAngle());\n }\n\n /**\n * @private\n */\n resetAnchor_() {\n this.set(ANCHOR_PROP, getFeaturesCentroid(this.features_), true);\n\n if (this.getAnchor()) {\n this.arrowFeature_ && this.arrowFeature_.getGeometry().setCoordinates(this.getAnchor());\n this.anchorFeature_ && this.anchorFeature_.getGeometry().setCoordinates(this.getAnchor());\n }\n }\n\n /**\n * @private\n */\n onFeatureAdd_ () {\n this.resetAngleAndAnchor_()\n this.createOrUpdateAnchorFeature_()\n this.createOrUpdateArrowFeature_()\n }\n\n /**\n * @private\n */\n onFeatureRemove_ () {\n this.resetAngleAndAnchor_()\n\n if (this.features_.getLength()) {\n this.createOrUpdateAnchorFeature_()\n this.createOrUpdateArrowFeature_()\n } else {\n this.overlay_.getSource().clear()\n this.anchorFeature_ = this.arrowFeature_ = undefined\n }\n }\n\n /**\n * @private\n */\n onAngleChange_({ oldValue }) {\n this.features_.forEach(feature => feature.getGeometry().rotate(this.getAngle() - oldValue, this.getAnchor()))\n this.arrowFeature_ && this.arrowFeature_.set(ANGLE_PROP, this.getAngle())\n this.anchorFeature_ && this.anchorFeature_.set(ANGLE_PROP, this.getAngle())\n }\n\n /**\n * @private\n */\n onAnchorChange_() {\n const anchor = this.getAnchor()\n\n if (anchor) {\n this.anchorFeature_ && this.anchorFeature_.getGeometry().setCoordinates(anchor)\n this.arrowFeature_ && this.arrowFeature_.getGeometry().setCoordinates(anchor)\n }\n }\n\n /**\n * @param {ol.Collection} features\n * @private\n */\n dispatchRotateStartEvent_ (features) {\n this.dispatchEvent(\n new RotateFeatureEvent(\n RotateFeatureEventType.START,\n features,\n this.getAngle(),\n this.getAnchor()\n )\n )\n }\n\n /**\n * @param {ol.Collection} features\n * @private\n */\n dispatchRotatingEvent_ (features) {\n this.dispatchEvent(\n new RotateFeatureEvent(\n RotateFeatureEventType.ROTATING,\n features,\n this.getAngle(),\n this.getAnchor()\n )\n )\n }\n\n /**\n * @param {ol.Collection} features\n * @private\n */\n dispatchRotateEndEvent_ (features) {\n this.dispatchEvent(\n new RotateFeatureEvent(\n RotateFeatureEventType.END,\n features,\n this.getAngle(),\n this.getAnchor()\n )\n )\n }\n}\n\n/**\n * @param {ol.MapBrowserEvent} evt Map browser event.\n * @return {boolean} `false` to stop event propagation.\n * @this {RotateFeatureInteraction}\n * @private\n */\nfunction handleEvent (evt) {\n // disable selection of inner features\n const foundFeature = evt.map.forEachFeatureAtPixel(evt.pixel, identity)\n if (\n includes([ 'click', 'singleclick', 'dblclick' ], evt.type) &&\n includes([ this.anchorFeature_, this.arrowFeature_ ], foundFeature)\n ) {\n return false\n }\n\n return this::PointerInteraction.handleEvent(evt)\n}\n\n/**\n * @param {ol.MapBrowserEvent} evt Event.\n * @return {boolean}\n * @this {RotateFeatureInteraction}\n * @private\n */\nfunction handleDownEvent (evt) {\n const foundFeature = evt.map.forEachFeatureAtPixel(evt.pixel, identity)\n\n // handle click & drag on features for rotation\n if (\n foundFeature && !this.lastCoordinate_ &&\n (\n includes(this.features_.getArray(), foundFeature) ||\n foundFeature === this.arrowFeature_\n )\n ) {\n this.lastCoordinate_ = evt.coordinate\n\n this::handleMoveEvent(evt)\n this.dispatchRotateStartEvent_(this.features_)\n\n return true\n }\n // handle click & drag on rotation anchor feature\n else if (foundFeature && foundFeature === this.anchorFeature_) {\n this.anchorMoving_ = true\n this::handleMoveEvent(evt)\n\n return true\n }\n\n return false\n}\n\n/**\n * @param {ol.MapBrowserEvent} evt Event.\n * @return {boolean}\n * @this {RotateFeatureInteraction}\n * @private\n */\nfunction handleUpEvent (evt) {\n // stop drag sequence of features\n if (this.lastCoordinate_) {\n this.lastCoordinate_ = undefined\n\n this::handleMoveEvent(evt)\n this.dispatchRotateEndEvent_(this.features_)\n\n return true\n }\n // stop drag sequence of the anchors\n else if (this.anchorMoving_) {\n this.anchorMoving_ = false\n this::handleMoveEvent(evt)\n\n return true\n }\n\n return false\n}\n\n/**\n * @param {ol.MapBrowserEvent} evt Event.\n * @return {boolean}\n * @this {RotateFeatureInteraction}\n * @private\n */\nfunction handleDragEvent ({ coordinate }) {\n const anchorCoordinate = this.anchorFeature_.getGeometry().getCoordinates()\n\n // handle drag of features by angle\n if (this.lastCoordinate_) {\n // calculate vectors of last and current pointer positions\n const lastVector = [\n this.lastCoordinate_[ 0 ] - anchorCoordinate[ 0 ],\n this.lastCoordinate_[ 1 ] - anchorCoordinate[ 1 ]\n ]\n const newVector = [\n coordinate[ 0 ] - anchorCoordinate[ 0 ],\n coordinate[ 1 ] - anchorCoordinate[ 1 ]\n ]\n\n // calculate angle between last and current vectors (positive angle counter-clockwise)\n let angle = Math.atan2(\n lastVector[ 0 ] * newVector[ 1 ] - newVector[ 0 ] * lastVector[ 1 ],\n lastVector[ 0 ] * newVector[ 0 ] + lastVector[ 1 ] * newVector[ 1 ]\n )\n\n this.setAngle(this.getAngle() + angle)\n this.dispatchRotatingEvent_(this.features_)\n\n this.lastCoordinate_ = coordinate\n }\n // handle drag of the anchor\n else if (this.anchorMoving_) {\n this.setAnchor(coordinate)\n }\n}\n\n/**\n * @param {ol.MapBrowserEvent} evt Event.\n * @return {boolean}\n * @this {RotateFeatureInteraction}\n * @private\n */\nfunction handleMoveEvent ({ map, pixel }) {\n const elem = map.getTargetElement()\n const foundFeature = map.forEachFeatureAtPixel(pixel, identity)\n\n const setCursor = (cursor, vendor = false) => {\n if (vendor) {\n elem.style.cursor = '-webkit-' + cursor\n elem.style.cursor = '-moz-' + cursor\n }\n\n elem.style.cursor = cursor\n }\n\n if (this.lastCoordinate_) {\n this.previousCursor_ = elem.style.cursor\n setCursor('grabbing', true)\n } else if (\n foundFeature &&\n (\n includes(this.features_.getArray(), foundFeature) ||\n foundFeature === this.arrowFeature_\n )\n ) {\n this.previousCursor_ = elem.style.cursor\n setCursor('grab', true)\n } else if (( foundFeature && foundFeature === this.anchorFeature_ ) || this.anchorMoving_) {\n this.previousCursor_ = elem.style.cursor\n setCursor('crosshair')\n } else {\n setCursor(this.previousCursor_ || '')\n this.previousCursor_ = undefined\n }\n}\n\n/**\n * @returns {StyleFunction}\n * @private\n */\nfunction getDefaultStyle () {\n const white = [ 255, 255, 255, 0.8 ]\n const blue = [ 0, 153, 255, 0.8 ]\n const transparent = [ 255, 255, 255, 0.01 ]\n const width = 2\n\n const styles = {\n [ ANCHOR_KEY ]: [\n new Style({\n image: new RegularShape({\n fill: new Fill({\n color: [ 0, 153, 255, 0.8 ]\n }),\n stroke: new Stroke({\n color: blue,\n width: 1\n }),\n radius: 4,\n points: 6\n }),\n zIndex: Infinity\n })\n ],\n [ ARROW_KEY ]: [\n new Style({\n fill: new Fill({\n color: transparent\n }),\n stroke: new Stroke({\n color: white,\n width: width + 2\n }),\n text: new Text({\n font: '12px sans-serif',\n offsetX: 20,\n offsetY: -20,\n fill: new Fill({\n color: 'blue'\n }),\n stroke: new Stroke({\n color: white,\n width: width + 1\n })\n }),\n zIndex: Infinity\n }),\n new Style({\n fill: new Fill({\n color: transparent\n }),\n stroke: new Stroke({\n color: blue,\n width\n }),\n zIndex: Infinity\n })\n ]\n }\n\n return function (feature, resolution) {\n let style\n const angle = feature.get(ANGLE_PROP) || 0\n\n switch (true) {\n case feature.get(ANCHOR_KEY):\n style = styles[ ANCHOR_KEY ]\n style[ 0 ].getImage().setRotation(-angle)\n\n return style\n case feature.get(ARROW_KEY):\n style = styles[ ARROW_KEY ]\n\n const coordinates = feature.getGeometry().getCoordinates()\n // generate arrow polygon\n const geom = new Polygon([\n [\n [ coordinates[ 0 ], coordinates[ 1 ] - 6 * resolution ],\n [ coordinates[ 0 ] + 8 * resolution, coordinates[ 1 ] - 12 * resolution ],\n [ coordinates[ 0 ], coordinates[ 1 ] + 30 * resolution ],\n [ coordinates[ 0 ] - 8 * resolution, coordinates[ 1 ] - 12 * resolution ],\n [ coordinates[ 0 ], coordinates[ 1 ] - 6 * resolution ],\n ]\n ])\n\n // and rotate it according to current angle\n geom.rotate(angle, coordinates)\n style[ 0 ].setGeometry(geom)\n style[ 1 ].setGeometry(geom)\n style[ 0 ].getText().setText(Math.round(-angle * 180 / Math.PI) + '°')\n\n return style\n }\n }\n}\n\n/**\n * @param {ol.Collection|Array} features\n * @returns {ol.Extent | undefined}\n * @private\n */\nfunction getFeaturesExtent (features) {\n features = features instanceof Collection ? features.getArray() : features\n if (!features.length) return\n\n return new GeometryCollection(features.map(feature => feature.getGeometry())).getExtent()\n}\n\n/**\n * @param {ol.Collection | Array} features\n * @return {ol.Coordinate | undefined}\n */\nfunction getFeaturesCentroid (features) {\n features = features instanceof Collection ? features.getArray() : features\n if (!features.length) return\n\n return extentHelper.getCenter(getFeaturesExtent(features))\n}\n","/**\n * Rotate interaction for OpenLayers.\n * Allows vector feature rotation.\n *\n * @author Vladimir Vershinin \n * @licence MIT https://opensource.org/licenses/MIT\n * @copyright (c) 2016-2017, Vladimir Vershinin\n */\nimport RotateFeatureInteraction from \"./interaction\"\n\n// for backward compatibility\nif (typeof window !== 'undefined' && window.ol) {\n window.ol.interaction.RotateFeature = RotateFeatureInteraction\n}\n\nexport default RotateFeatureInteraction\n"],"names":["assert","condition","message","join","Error","identity","arg","includes","arr","value","indexOf","isArray","val","Object","prototype","toString","RotateFeatureEventType","RotateFeatureEvent","type","features","angle","anchor","propagationStopped_","type_","features_","angle_","anchor_","ANCHOR_KEY","ARROW_KEY","ANGLE_PROP","ANCHOR_PROP","RotateFeatureInteraction","options","handleEvent","handleDownEvent","handleUpEvent","handleDragEvent","handleMoveEvent","previousCursor_","undefined","anchorFeature_","arrowFeature_","lastCoordinate_","anchorMoving_","overlay_","VectorLayer","style","getDefaultStyle","VectorSource","Collection","setAnchor","getFeaturesCentroid","setAngle","on","onFeatureAdd_","onFeatureRemove_","onAngleChange_","onAnchorChange_","createOrUpdateAnchorFeature_","createOrUpdateArrowFeature_","map","setMap","active","isNaN","parseFloat","set","get","length","getAngle","getAnchor","getGeometry","setCoordinates","Feature","Point","getSource","addFeature","resetAngle_","resetAnchor_","resetAngleAndAnchor_","getLength","clear","oldValue","forEach","feature","rotate","dispatchEvent","START","ROTATING","END","getMap","setActive","getActive","PointerInteraction","evt","foundFeature","forEachFeatureAtPixel","pixel","getArray","coordinate","dispatchRotateStartEvent_","dispatchRotateEndEvent_","anchorCoordinate","getCoordinates","lastVector","newVector","Math","atan2","dispatchRotatingEvent_","elem","getTargetElement","setCursor","cursor","vendor","white","blue","transparent","width","styles","Style","RegularShape","Fill","Stroke","Infinity","Text","resolution","getImage","setRotation","coordinates","geom","Polygon","setGeometry","getText","setText","round","PI","getFeaturesExtent","GeometryCollection","getExtent","extentHelper","getCenter","window","ol","interaction","RotateFeature"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;AAKA,AAAO,SAASA,MAAT,CAAiBC,SAAjB,EAA0C;MAAdC,OAAc,uEAAJ,EAAI;;YACrC,CAAE,kBAAF,EAAsBA,OAAtB,EAAgCC,IAAhC,CAAqC,IAArC,CAAV;;MAEI,CAACF,SAAL,EAAgB;UACR,IAAIG,KAAJ,CAAUF,OAAV,CAAN;;;;;;;;AAQJ,AAAO,SAASG,QAAT,CAAmBC,GAAnB,EAAwB;SACtBA,GAAP;;;;;;;AAOF;;AAIA,AACA;;;;AAIA;;AAOA,AAAO,SAASC,QAAT,CAAmBC,GAAnB,EAAwBC,KAAxB,EAA+B;SAC7BD,IAAIE,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OyH,MAAP,KAAkB,WAAlB,IAAiCA,OAAOC,EAA5C,EAAgD;SACvCA,EAAP,CAAUC,WAAV,CAAsBC,aAAtB,GAAsChH,wBAAtC;;;;;"} \ No newline at end of file diff --git a/dist/bundle.js b/dist/bundle.js deleted file mode 100644 index ae53672..0000000 --- a/dist/bundle.js +++ /dev/null @@ -1,1044 +0,0 @@ -/*! -Rotate vector features interaction for OpenLayers - -@package ol-rotate-feature -@author Vladimir Vershinin -@version 1.3.0 -@licence MIT -@copyright (c) 2016-2018, Vladimir Vershinin -*/ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('openlayers')) : - typeof define === 'function' && define.amd ? define('ol-rotate-feature', ['openlayers'], factory) : - (global.RotateFeatureInteraction = factory(global.ol)); -}(this, (function (__ol__) { 'use strict'; - -__ol__ = __ol__ && __ol__.hasOwnProperty('default') ? __ol__['default'] : __ol__; - -/** - * @param {boolean} condition - * @param {string} message - * @throws Error - */ -function assert(condition) { - var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; - - message = ['Assertion failed', message].join(': '); - - if (!condition) { - throw new Error(message); - } -} - -/** - * @param {*} arg - * @returns {*} - */ -function identity(arg) { - return arg; -} - -/** - * @param {...*} args - * @return {*} - */ - - -/** - * @param {string} [prefix] - * @return {number} - */ - - -function includes(arr, value) { - return arr.indexOf(value) !== -1; -} - -function isArray(val) { - return Object.prototype.toString.call(val) === '[object Array]'; -} - -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { - return typeof obj; -} : function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; -}; - - - - - - - - - - - -var classCallCheck = function (instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } -}; - -var createClass = function () { - function defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); - } - } - - return function (Constructor, protoProps, staticProps) { - if (protoProps) defineProperties(Constructor.prototype, protoProps); - if (staticProps) defineProperties(Constructor, staticProps); - return Constructor; - }; -}(); - - - - - -var defineProperty = function (obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - - return obj; -}; - -var get = function get(object, property, receiver) { - if (object === null) object = Function.prototype; - var desc = Object.getOwnPropertyDescriptor(object, property); - - if (desc === undefined) { - var parent = Object.getPrototypeOf(object); - - if (parent === null) { - return undefined; - } else { - return get(parent, property, receiver); - } - } else if ("value" in desc) { - return desc.value; - } else { - var getter = desc.get; - - if (getter === undefined) { - return undefined; - } - - return getter.call(receiver); - } -}; - -var inherits = function (subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); - } - - subClass.prototype = Object.create(superClass && superClass.prototype, { - constructor: { - value: subClass, - enumerable: false, - writable: true, - configurable: true - } - }); - if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; -}; - - - - - - - - - - - -var possibleConstructorReturn = function (self, call) { - if (!self) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - - return call && (typeof call === "object" || typeof call === "function") ? call : self; -}; - -/** - * @enum {string} - */ -var RotateFeatureEventType = { - /** - * Triggered upon feature rotate start. - * @event RotateFeatureEvent#rotatestart - */ - START: 'rotatestart', - /** - * Triggered upon feature rotation. - * @event RotateFeatureEvent#rotating - */ - ROTATING: 'rotating', - /** - * Triggered upon feature rotation end. - * @event RotateFeatureEvent#rotateend - */ - END: 'rotateend' - - /** - * Events emitted by RotateFeatureInteraction instances are instances of this type. - * - * @class - * @author Vladimir Vershinin - */ -}; -var RotateFeatureEvent = function () { - /** - * @param {string} type Type. - * @param {ol.Collection} features Rotated features. - * @param {number} angle Angle in radians. - * @param {ol.Coordinate} anchor Anchor position. - */ - function RotateFeatureEvent(type, features, angle, anchor) { - classCallCheck(this, RotateFeatureEvent); - - /** - * @type {boolean} - * @private - */ - this.propagationStopped_ = false; - - /** - * The event type. - * @type {string} - * @private - */ - this.type_ = type; - - /** - * The features being rotated. - * @type {ol.Collection} - * @private - */ - this.features_ = features; - /** - * Current angle in radians. - * @type {number} - * @private - */ - this.angle_ = angle; - /** - * Current rotation anchor. - * @type {ol.Coordinate} - * @private - */ - this.anchor_ = anchor; - } - - /** - * @type {boolean} - */ - - - createClass(RotateFeatureEvent, [{ - key: 'preventDefault', - - - /** - * Prevent event propagation. - */ - value: function preventDefault() { - this.propagationStopped_ = true; - } - - /** - * Stop event propagation. - */ - - }, { - key: 'stopPropagation', - value: function stopPropagation() { - this.propagationStopped_ = true; - } - }, { - key: 'propagationStopped', - get: function get$$1() { - return this.propagationStopped_; - } - - /** - * @type {RotateFeatureEventType} - */ - - }, { - key: 'type', - get: function get$$1() { - return this.type_; - } - - /** - * @type {ol.Collection} - */ - - }, { - key: 'features', - get: function get$$1() { - return this.features_; - } - - /** - * @type {number} - */ - - }, { - key: 'angle', - get: function get$$1() { - return this.angle_; - } - - /** - * @type {ol.Coordinate} - */ - - }, { - key: 'anchor', - get: function get$$1() { - return this.anchor_; - } - }]); - return RotateFeatureEvent; -}(); - -/** - * Rotate interaction class. - * Adds controls to rotate vector features. - * Writes out total angle in radians (positive is counter-clockwise) to property for each feature. - */ -var PointerInteraction = __ol__.interaction.Pointer; -var Collection = __ol__.Collection; -var VectorLayer = __ol__.layer.Vector; -var VectorSource = __ol__.source.Vector; -var Feature = __ol__.Feature; -var Point = __ol__.geom.Point; -var Polygon = __ol__.geom.Polygon; -var GeometryCollection = __ol__.geom.GeometryCollection; -var Style = __ol__.style.Style; -var RegularShape = __ol__.style.RegularShape; -var Stroke = __ol__.style.Stroke; -var Fill = __ol__.style.Fill; -var Text = __ol__.style.Text; -var extentHelper = __ol__.extent; -var ANCHOR_KEY = 'rotate-anchor'; -var ARROW_KEY = 'rotate-arrow'; - -var ANGLE_PROP = 'angle'; -var ANCHOR_PROP = 'anchor'; - -/** - * @todo todo добавить опцию condition - для возможности переопределения клавиш - */ - -var RotateFeatureInteraction = function (_PointerInteraction) { - inherits(RotateFeatureInteraction, _PointerInteraction); - - /** - * @param {InteractionOptions} options - */ - function RotateFeatureInteraction() { - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - classCallCheck(this, RotateFeatureInteraction); - - /** - * @type {string} - * @private - */ - var _this = possibleConstructorReturn(this, (RotateFeatureInteraction.__proto__ || Object.getPrototypeOf(RotateFeatureInteraction)).call(this, { - handleEvent: handleEvent, - handleDownEvent: handleDownEvent, - handleUpEvent: handleUpEvent, - handleDragEvent: handleDragEvent, - handleMoveEvent: handleMoveEvent - })); - - _this.previousCursor_ = undefined; - /** - * @type {ol.Feature} - * @private - */ - _this.anchorFeature_ = undefined; - /** - * @type {ol.Feature} - * @private - */ - _this.arrowFeature_ = undefined; - /** - * @type {ol.Coordinate} - * @private - */ - _this.lastCoordinate_ = undefined; - /** - * @type {boolean} - * @private - */ - _this.anchorMoving_ = false; - /** - * @type {ol.layer.Vector} - * @private - */ - _this.overlay_ = new VectorLayer({ - style: options.style || getDefaultStyle(), - source: new VectorSource({ - features: new Collection() - }) - }); - /** - * @type {ol.Collection} - * @private - */ - _this.features_ = undefined; - if (options.features) { - if (isArray(options.features)) { - _this.features_ = new Collection(options.features); - } else if (options.features instanceof Collection) { - _this.features_ = options.features; - } else { - throw new Error('Features option should be an array or collection of features, ' + 'got ' + _typeof(options.features)); - } - } else { - _this.features_ = new Collection(); - } - - _this.setAnchor(options.anchor || getFeaturesCentroid(_this.features_)); - _this.setAngle(options.angle || 0); - - _this.features_.on('add', _this.onFeatureAdd_.bind(_this)); - _this.features_.on('remove', _this.onFeatureRemove_.bind(_this)); - _this.on('change:' + ANGLE_PROP, _this.onAngleChange_.bind(_this)); - _this.on('change:' + ANCHOR_PROP, _this.onAnchorChange_.bind(_this)); - - _this.createOrUpdateAnchorFeature_(); - _this.createOrUpdateArrowFeature_(); - return _this; - } - - /** - * @type {ol.Collection} - */ - - - createClass(RotateFeatureInteraction, [{ - key: 'setMap', - - - /** - * @param {ol.Map} map - */ - value: function setMap(map) { - this.overlay_.setMap(map); - get(RotateFeatureInteraction.prototype.__proto__ || Object.getPrototypeOf(RotateFeatureInteraction.prototype), 'setMap', this).call(this, map); - } - - /** - * @param {boolean} active - */ - - }, { - key: 'setActive', - value: function setActive(active) { - if (this.overlay_) { - this.overlay_.setMap(active ? this.map : undefined); - } - - get(RotateFeatureInteraction.prototype.__proto__ || Object.getPrototypeOf(RotateFeatureInteraction.prototype), 'setActive', this).call(this, active); - } - - /** - * Set current angle of interaction features. - * - * @param {number} angle - */ - - }, { - key: 'setAngle', - value: function setAngle(angle) { - assert(!isNaN(parseFloat(angle)), 'Numeric value passed'); - - this.set(ANGLE_PROP, parseFloat(angle)); - } - - /** - * Returns current angle of interaction features. - * - * @return {number} - */ - - }, { - key: 'getAngle', - value: function getAngle() { - return this.get(ANGLE_PROP); - } - - /** - * Set current anchor position. - * - * @param {ol.Coordinate | undefined} anchor - */ - - }, { - key: 'setAnchor', - value: function setAnchor(anchor) { - assert(anchor == null || isArray(anchor) && anchor.length === 2, 'Array of two elements passed'); - - this.set(ANCHOR_PROP, anchor != null ? anchor.map(parseFloat) : getFeaturesCentroid(this.features_)); - } - - /** - * Returns current anchor position. - * - * @return {ol.Coordinate | undefined} - */ - - }, { - key: 'getAnchor', - value: function getAnchor() { - return this.get(ANCHOR_PROP); - } - - /** - * @private - */ - - }, { - key: 'createOrUpdateAnchorFeature_', - value: function createOrUpdateAnchorFeature_() { - var angle = this.getAngle(); - var anchor = this.getAnchor(); - - if (!anchor) return; - - if (this.anchorFeature_) { - this.anchorFeature_.getGeometry().setCoordinates(anchor); - this.anchorFeature_.set(ANGLE_PROP, angle); - } else { - var _ref; - - this.anchorFeature_ = new Feature((_ref = { - geometry: new Point(anchor) - }, defineProperty(_ref, ANGLE_PROP, angle), defineProperty(_ref, ANCHOR_KEY, true), _ref)); - this.overlay_.getSource().addFeature(this.anchorFeature_); - } - } - - /** - * @private - */ - - }, { - key: 'createOrUpdateArrowFeature_', - value: function createOrUpdateArrowFeature_() { - var angle = this.getAngle(); - var anchor = this.getAnchor(); - - if (!anchor) return; - - if (this.arrowFeature_) { - this.arrowFeature_.getGeometry().setCoordinates(anchor); - this.arrowFeature_.set(ANGLE_PROP, angle); - } else { - var _ref2; - - this.arrowFeature_ = new Feature((_ref2 = { - geometry: new Point(anchor) - }, defineProperty(_ref2, ANGLE_PROP, angle), defineProperty(_ref2, ARROW_KEY, true), _ref2)); - this.overlay_.getSource().addFeature(this.arrowFeature_); - } - } - - /** - * @private - */ - - }, { - key: 'resetAngleAndAnchor_', - value: function resetAngleAndAnchor_() { - this.resetAngle_(); - this.resetAnchor_(); - } - - /** - * @private - */ - - }, { - key: 'resetAngle_', - value: function resetAngle_() { - this.set(ANGLE_PROP, 0, true); - this.arrowFeature_ && this.arrowFeature_.set(ANGLE_PROP, this.getAngle()); - this.anchorFeature_ && this.anchorFeature_.set(ANGLE_PROP, this.getAngle()); - } - - /** - * @private - */ - - }, { - key: 'resetAnchor_', - value: function resetAnchor_() { - this.set(ANCHOR_PROP, getFeaturesCentroid(this.features_), true); - - if (this.getAnchor()) { - this.arrowFeature_ && this.arrowFeature_.getGeometry().setCoordinates(this.getAnchor()); - this.anchorFeature_ && this.anchorFeature_.getGeometry().setCoordinates(this.getAnchor()); - } - } - - /** - * @private - */ - - }, { - key: 'onFeatureAdd_', - value: function onFeatureAdd_() { - this.resetAngleAndAnchor_(); - this.createOrUpdateAnchorFeature_(); - this.createOrUpdateArrowFeature_(); - } - - /** - * @private - */ - - }, { - key: 'onFeatureRemove_', - value: function onFeatureRemove_() { - this.resetAngleAndAnchor_(); - - if (this.features_.getLength()) { - this.createOrUpdateAnchorFeature_(); - this.createOrUpdateArrowFeature_(); - } else { - this.overlay_.getSource().clear(); - this.anchorFeature_ = this.arrowFeature_ = undefined; - } - } - - /** - * @private - */ - - }, { - key: 'onAngleChange_', - value: function onAngleChange_(_ref3) { - var _this2 = this; - - var oldValue = _ref3.oldValue; - - this.features_.forEach(function (feature) { - return feature.getGeometry().rotate(_this2.getAngle() - oldValue, _this2.getAnchor()); - }); - this.arrowFeature_ && this.arrowFeature_.set(ANGLE_PROP, this.getAngle()); - this.anchorFeature_ && this.anchorFeature_.set(ANGLE_PROP, this.getAngle()); - } - - /** - * @private - */ - - }, { - key: 'onAnchorChange_', - value: function onAnchorChange_() { - var anchor = this.getAnchor(); - - if (anchor) { - this.anchorFeature_ && this.anchorFeature_.getGeometry().setCoordinates(anchor); - this.arrowFeature_ && this.arrowFeature_.getGeometry().setCoordinates(anchor); - } - } - - /** - * @param {ol.Collection} features - * @private - */ - - }, { - key: 'dispatchRotateStartEvent_', - value: function dispatchRotateStartEvent_(features) { - this.dispatchEvent(new RotateFeatureEvent(RotateFeatureEventType.START, features, this.getAngle(), this.getAnchor())); - } - - /** - * @param {ol.Collection} features - * @private - */ - - }, { - key: 'dispatchRotatingEvent_', - value: function dispatchRotatingEvent_(features) { - this.dispatchEvent(new RotateFeatureEvent(RotateFeatureEventType.ROTATING, features, this.getAngle(), this.getAnchor())); - } - - /** - * @param {ol.Collection} features - * @private - */ - - }, { - key: 'dispatchRotateEndEvent_', - value: function dispatchRotateEndEvent_(features) { - this.dispatchEvent(new RotateFeatureEvent(RotateFeatureEventType.END, features, this.getAngle(), this.getAnchor())); - } - }, { - key: 'features', - get: function get$$1() { - return this.features_; - } - - /** - * @type {number} - */ - - }, { - key: 'angle', - get: function get$$1() { - return this.getAngle(); - } - - /** - * @param {number} angle - */ - , - set: function set$$1(angle) { - this.setAngle(angle); - } - - /** - * @type {ol.Coordinate|undefined} - */ - - }, { - key: 'anchor', - get: function get$$1() { - return this.getAnchor(); - } - - /** - * @param {ol.Coordinate|undefined} anchor - */ - , - set: function set$$1(anchor) { - this.setAnchor(anchor); - } - - /** - * @param {ol.Map} map - */ - - }, { - key: 'map', - set: function set$$1(map) { - this.setMap(map); - } - - /** - * @type {ol.Map} - */ - , - get: function get$$1() { - return this.getMap(); - } - - /** - * @param {boolean} active - */ - - }, { - key: 'active', - set: function set$$1(active) { - this.setActive(active); - } - - /** - * @type {boolean} - */ - , - get: function get$$1() { - return this.getActive(); - } - }]); - return RotateFeatureInteraction; -}(PointerInteraction); - -function handleEvent(evt) { - // disable selection of inner features - var foundFeature = evt.map.forEachFeatureAtPixel(evt.pixel, identity); - if (includes(['click', 'singleclick', 'dblclick'], evt.type) && includes([this.anchorFeature_, this.arrowFeature_], foundFeature)) { - return false; - } - - return PointerInteraction.handleEvent.call(this, evt); -} - -/** - * @param {ol.MapBrowserEvent} evt Event. - * @return {boolean} - * @this {RotateFeatureInteraction} - * @private - */ -function handleDownEvent(evt) { - var foundFeature = evt.map.forEachFeatureAtPixel(evt.pixel, identity); - - // handle click & drag on features for rotation - if (foundFeature && !this.lastCoordinate_ && (includes(this.features_.getArray(), foundFeature) || foundFeature === this.arrowFeature_)) { - this.lastCoordinate_ = evt.coordinate; - - handleMoveEvent.call(this, evt); - this.dispatchRotateStartEvent_(this.features_); - - return true; - } - // handle click & drag on rotation anchor feature - else if (foundFeature && foundFeature === this.anchorFeature_) { - this.anchorMoving_ = true; - handleMoveEvent.call(this, evt); - - return true; - } - - return false; -} - -/** - * @param {ol.MapBrowserEvent} evt Event. - * @return {boolean} - * @this {RotateFeatureInteraction} - * @private - */ -function handleUpEvent(evt) { - // stop drag sequence of features - if (this.lastCoordinate_) { - this.lastCoordinate_ = undefined; - - handleMoveEvent.call(this, evt); - this.dispatchRotateEndEvent_(this.features_); - - return true; - } - // stop drag sequence of the anchors - else if (this.anchorMoving_) { - this.anchorMoving_ = false; - handleMoveEvent.call(this, evt); - - return true; - } - - return false; -} - -/** - * @param {ol.MapBrowserEvent} evt Event. - * @return {boolean} - * @this {RotateFeatureInteraction} - * @private - */ -function handleDragEvent(_ref4) { - var coordinate = _ref4.coordinate; - - var anchorCoordinate = this.anchorFeature_.getGeometry().getCoordinates(); - - // handle drag of features by angle - if (this.lastCoordinate_) { - // calculate vectors of last and current pointer positions - var lastVector = [this.lastCoordinate_[0] - anchorCoordinate[0], this.lastCoordinate_[1] - anchorCoordinate[1]]; - var newVector = [coordinate[0] - anchorCoordinate[0], coordinate[1] - anchorCoordinate[1]]; - - // calculate angle between last and current vectors (positive angle counter-clockwise) - var angle = Math.atan2(lastVector[0] * newVector[1] - newVector[0] * lastVector[1], lastVector[0] * newVector[0] + lastVector[1] * newVector[1]); - - this.setAngle(this.getAngle() + angle); - this.dispatchRotatingEvent_(this.features_); - - this.lastCoordinate_ = coordinate; - } - // handle drag of the anchor - else if (this.anchorMoving_) { - this.setAnchor(coordinate); - } -} - -/** - * @param {ol.MapBrowserEvent} evt Event. - * @return {boolean} - * @this {RotateFeatureInteraction} - * @private - */ -function handleMoveEvent(_ref5) { - var map = _ref5.map, - pixel = _ref5.pixel; - - var elem = map.getTargetElement(); - var foundFeature = map.forEachFeatureAtPixel(pixel, identity); - - var setCursor = function setCursor(cursor) { - var vendor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - - if (vendor) { - elem.style.cursor = '-webkit-' + cursor; - elem.style.cursor = '-moz-' + cursor; - } - - elem.style.cursor = cursor; - }; - - if (this.lastCoordinate_) { - this.previousCursor_ = elem.style.cursor; - setCursor('grabbing', true); - } else if (foundFeature && (includes(this.features_.getArray(), foundFeature) || foundFeature === this.arrowFeature_)) { - this.previousCursor_ = elem.style.cursor; - setCursor('grab', true); - } else if (foundFeature && foundFeature === this.anchorFeature_ || this.anchorMoving_) { - this.previousCursor_ = elem.style.cursor; - setCursor('crosshair'); - } else { - setCursor(this.previousCursor_ || ''); - this.previousCursor_ = undefined; - } -} - -/** - * @returns {StyleFunction} - * @private - */ -function getDefaultStyle() { - var _styles; - - var white = [255, 255, 255, 0.8]; - var blue = [0, 153, 255, 0.8]; - var transparent = [255, 255, 255, 0.01]; - var width = 2; - - var styles = (_styles = {}, defineProperty(_styles, ANCHOR_KEY, [new Style({ - image: new RegularShape({ - fill: new Fill({ - color: [0, 153, 255, 0.8] - }), - stroke: new Stroke({ - color: blue, - width: 1 - }), - radius: 4, - points: 6 - }), - zIndex: Infinity - })]), defineProperty(_styles, ARROW_KEY, [new Style({ - fill: new Fill({ - color: transparent - }), - stroke: new Stroke({ - color: white, - width: width + 2 - }), - text: new Text({ - font: '12px sans-serif', - offsetX: 20, - offsetY: -20, - fill: new Fill({ - color: 'blue' - }), - stroke: new Stroke({ - color: white, - width: width + 1 - }) - }), - zIndex: Infinity - }), new Style({ - fill: new Fill({ - color: transparent - }), - stroke: new Stroke({ - color: blue, - width: width - }), - zIndex: Infinity - })]), _styles); - - return function (feature, resolution) { - var style = void 0; - var angle = feature.get(ANGLE_PROP) || 0; - - switch (true) { - case feature.get(ANCHOR_KEY): - style = styles[ANCHOR_KEY]; - style[0].getImage().setRotation(-angle); - - return style; - case feature.get(ARROW_KEY): - style = styles[ARROW_KEY]; - - var coordinates = feature.getGeometry().getCoordinates(); - // generate arrow polygon - var geom = new Polygon([[[coordinates[0], coordinates[1] - 6 * resolution], [coordinates[0] + 8 * resolution, coordinates[1] - 12 * resolution], [coordinates[0], coordinates[1] + 30 * resolution], [coordinates[0] - 8 * resolution, coordinates[1] - 12 * resolution], [coordinates[0], coordinates[1] - 6 * resolution]]]); - - // and rotate it according to current angle - geom.rotate(angle, coordinates); - style[0].setGeometry(geom); - style[1].setGeometry(geom); - style[0].getText().setText(Math.round(-angle * 180 / Math.PI) + '°'); - - return style; - } - }; -} - -/** - * @param {ol.Collection|Array} features - * @returns {ol.Extent | undefined} - * @private - */ -function getFeaturesExtent(features) { - features = features instanceof Collection ? features.getArray() : features; - if (!features.length) return; - - return new GeometryCollection(features.map(function (feature) { - return feature.getGeometry(); - })).getExtent(); -} - -/** - * @param {ol.Collection | Array} features - * @return {ol.Coordinate | undefined} - */ -function getFeaturesCentroid(features) { - features = features instanceof Collection ? features.getArray() : features; - if (!features.length) return; - - return extentHelper.getCenter(getFeaturesExtent(features)); -} - -/** - * Rotate interaction for OpenLayers. - * Allows vector feature rotation. - * - * @author Vladimir Vershinin - * @licence MIT https://opensource.org/licenses/MIT - * @copyright (c) 2016-2017, Vladimir Vershinin - */ -// for backward compatibility -if (typeof window !== 'undefined' && window.ol) { - window.ol.interaction.RotateFeature = RotateFeatureInteraction; -} - -return RotateFeatureInteraction; - -}))); -//# sourceMappingURL=bundle.js.map diff --git a/dist/bundle.js.map b/dist/bundle.js.map deleted file mode 100644 index e65f099..0000000 --- a/dist/bundle.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"bundle.js","sources":["../src/util.js","../src/event.js","../src/interaction.js","../src/index.js"],"sourcesContent":["/**\n * @param {boolean} condition\n * @param {string} message\n * @throws Error\n */\nexport function assert (condition, message = '') {\n message = [ 'Assertion failed', message ].join(': ')\n\n if (!condition) {\n throw new Error(message)\n }\n}\n\n/**\n * @param {*} arg\n * @returns {*}\n */\nexport function identity (arg) {\n return arg\n}\n\n/**\n * @param {...*} args\n * @return {*}\n */\nexport function coalesce (...args) {\n return args.filter(value => value != null).shift()\n}\n\nconst counters = {}\n/**\n * @param {string} [prefix]\n * @return {number}\n */\nexport function uniqId (prefix = '') {\n const ns = prefix || 'default'\n counters[ ns ] = counters[ ns ] == null ? 0 : counters[ ns ]\n\n return String(prefix) + (++counters[ ns ])\n}\n\nexport function includes (arr, value) {\n return arr.indexOf(value) !== -1\n}\n\nexport function isArray (val) {\n return val::Object.prototype.toString() === '[object Array]'\n}\n","/**\n * @enum {string}\n */\nexport const RotateFeatureEventType = {\n /**\n * Triggered upon feature rotate start.\n * @event RotateFeatureEvent#rotatestart\n */\n START: 'rotatestart',\n /**\n * Triggered upon feature rotation.\n * @event RotateFeatureEvent#rotating\n */\n ROTATING: 'rotating',\n /**\n * Triggered upon feature rotation end.\n * @event RotateFeatureEvent#rotateend\n */\n END: 'rotateend'\n}\n\n/**\n * Events emitted by RotateFeatureInteraction instances are instances of this type.\n *\n * @class\n * @author Vladimir Vershinin\n */\nexport default class RotateFeatureEvent {\n /**\n * @param {string} type Type.\n * @param {ol.Collection} features Rotated features.\n * @param {number} angle Angle in radians.\n * @param {ol.Coordinate} anchor Anchor position.\n */\n constructor (type, features, angle, anchor) {\n /**\n * @type {boolean}\n * @private\n */\n this.propagationStopped_ = false\n\n /**\n * The event type.\n * @type {string}\n * @private\n */\n this.type_ = type\n\n /**\n * The features being rotated.\n * @type {ol.Collection}\n * @private\n */\n this.features_ = features\n /**\n * Current angle in radians.\n * @type {number}\n * @private\n */\n this.angle_ = angle\n /**\n * Current rotation anchor.\n * @type {ol.Coordinate}\n * @private\n */\n this.anchor_ = anchor\n }\n\n /**\n * @type {boolean}\n */\n get propagationStopped () {\n return this.propagationStopped_\n }\n\n /**\n * @type {RotateFeatureEventType}\n */\n get type () {\n return this.type_\n }\n\n /**\n * @type {ol.Collection}\n */\n get features () {\n return this.features_\n }\n\n /**\n * @type {number}\n */\n get angle () {\n return this.angle_\n }\n\n /**\n * @type {ol.Coordinate}\n */\n get anchor () {\n return this.anchor_\n }\n\n /**\n * Prevent event propagation.\n */\n preventDefault () {\n this.propagationStopped_ = true\n }\n\n /**\n * Stop event propagation.\n */\n stopPropagation () {\n this.propagationStopped_ = true\n }\n}\n","/**\n * Rotate interaction class.\n * Adds controls to rotate vector features.\n * Writes out total angle in radians (positive is counter-clockwise) to property for each feature.\n */\nimport PointerInteraction from 'ol/interaction/pointer'\nimport Collection from 'ol/collection'\nimport VectorLayer from 'ol/layer/vector'\nimport VectorSource from 'ol/source/vector'\nimport Feature from 'ol/feature'\nimport Point from 'ol/geom/point'\nimport Polygon from 'ol/geom/polygon'\nimport GeometryCollection from 'ol/geom/geometrycollection'\nimport Style from 'ol/style/style'\nimport RegularShape from 'ol/style/regularshape'\nimport Stroke from 'ol/style/stroke'\nimport Fill from 'ol/style/fill'\nimport Text from 'ol/style/text'\nimport extentHelper from 'ol/extent'\nimport { assert, identity, includes, isArray } from './util'\nimport RotateFeatureEvent, { RotateFeatureEventType } from './event'\n\nconst ANCHOR_KEY = 'rotate-anchor'\nconst ARROW_KEY = 'rotate-arrow'\n\nconst ANGLE_PROP = 'angle'\nconst ANCHOR_PROP = 'anchor'\n\n/**\n * @todo todo добавить опцию condition - для возможности переопределения клавиш\n */\nexport default class RotateFeatureInteraction extends PointerInteraction {\n /**\n * @param {InteractionOptions} options\n */\n constructor (options = {}) {\n super({\n handleEvent: handleEvent,\n handleDownEvent: handleDownEvent,\n handleUpEvent: handleUpEvent,\n handleDragEvent: handleDragEvent,\n handleMoveEvent: handleMoveEvent\n })\n /**\n * @type {string}\n * @private\n */\n this.previousCursor_ = undefined\n /**\n * @type {ol.Feature}\n * @private\n */\n this.anchorFeature_ = undefined\n /**\n * @type {ol.Feature}\n * @private\n */\n this.arrowFeature_ = undefined\n /**\n * @type {ol.Coordinate}\n * @private\n */\n this.lastCoordinate_ = undefined\n /**\n * @type {boolean}\n * @private\n */\n this.anchorMoving_ = false\n /**\n * @type {ol.layer.Vector}\n * @private\n */\n this.overlay_ = new VectorLayer({\n style: options.style || getDefaultStyle(),\n source: new VectorSource({\n features: new Collection()\n })\n })\n /**\n * @type {ol.Collection}\n * @private\n */\n this.features_ = undefined\n if (options.features) {\n if (isArray(options.features)) {\n this.features_ = new Collection(options.features)\n } else if (options.features instanceof Collection) {\n this.features_ = options.features\n } else {\n throw new Error('Features option should be an array or collection of features, ' +\n 'got ' + (typeof options.features))\n }\n } else {\n this.features_ = new Collection()\n }\n\n this.setAnchor(options.anchor || getFeaturesCentroid(this.features_))\n this.setAngle(options.angle || 0)\n\n this.features_.on('add', ::this.onFeatureAdd_)\n this.features_.on('remove', ::this.onFeatureRemove_)\n this.on('change:' + ANGLE_PROP, ::this.onAngleChange_)\n this.on('change:' + ANCHOR_PROP, ::this.onAnchorChange_)\n\n this.createOrUpdateAnchorFeature_()\n this.createOrUpdateArrowFeature_()\n }\n\n /**\n * @type {ol.Collection}\n */\n get features () {\n return this.features_\n }\n\n /**\n * @type {number}\n */\n get angle () {\n return this.getAngle()\n }\n\n /**\n * @param {number} angle\n */\n set angle (angle) {\n this.setAngle(angle)\n }\n\n /**\n * @type {ol.Coordinate|undefined}\n */\n get anchor () {\n return this.getAnchor()\n }\n\n /**\n * @param {ol.Coordinate|undefined} anchor\n */\n set anchor (anchor) {\n this.setAnchor(anchor)\n }\n\n /**\n * @param {ol.Map} map\n */\n set map (map) {\n this.setMap(map)\n }\n\n /**\n * @type {ol.Map}\n */\n get map() {\n return this.getMap()\n }\n\n /**\n * @param {boolean} active\n */\n set active (active) {\n this.setActive(active)\n }\n\n /**\n * @type {boolean}\n */\n get active () {\n return this.getActive()\n }\n\n /**\n * @param {ol.Map} map\n */\n setMap (map) {\n this.overlay_.setMap(map)\n super.setMap(map)\n }\n\n /**\n * @param {boolean} active\n */\n setActive (active) {\n if (this.overlay_) {\n this.overlay_.setMap(active ? this.map : undefined)\n }\n\n super.setActive(active)\n }\n\n /**\n * Set current angle of interaction features.\n *\n * @param {number} angle\n */\n setAngle (angle) {\n assert(!isNaN(parseFloat(angle)), 'Numeric value passed')\n\n this.set(ANGLE_PROP, parseFloat(angle))\n }\n\n /**\n * Returns current angle of interaction features.\n *\n * @return {number}\n */\n getAngle () {\n return this.get(ANGLE_PROP)\n }\n\n /**\n * Set current anchor position.\n *\n * @param {ol.Coordinate | undefined} anchor\n */\n setAnchor (anchor) {\n assert(anchor == null || isArray(anchor) && anchor.length === 2, 'Array of two elements passed')\n\n this.set(ANCHOR_PROP, anchor != null ? anchor.map(parseFloat) : getFeaturesCentroid(this.features_))\n }\n\n /**\n * Returns current anchor position.\n *\n * @return {ol.Coordinate | undefined}\n */\n getAnchor () {\n return this.get(ANCHOR_PROP)\n }\n\n /**\n * @private\n */\n createOrUpdateAnchorFeature_ () {\n const angle = this.getAngle()\n const anchor = this.getAnchor()\n\n if (!anchor) return\n\n if (this.anchorFeature_) {\n this.anchorFeature_.getGeometry().setCoordinates(anchor)\n this.anchorFeature_.set(ANGLE_PROP, angle)\n } else {\n this.anchorFeature_ = new Feature({\n geometry: new Point(anchor),\n [ ANGLE_PROP ]: angle,\n [ ANCHOR_KEY ]: true\n })\n this.overlay_.getSource().addFeature(this.anchorFeature_)\n }\n }\n\n /**\n * @private\n */\n createOrUpdateArrowFeature_ () {\n const angle = this.getAngle()\n const anchor = this.getAnchor()\n\n if (!anchor) return\n\n if (this.arrowFeature_) {\n this.arrowFeature_.getGeometry().setCoordinates(anchor)\n this.arrowFeature_.set(ANGLE_PROP, angle)\n } else {\n this.arrowFeature_ = new Feature({\n geometry: new Point(anchor),\n [ ANGLE_PROP ]: angle,\n [ ARROW_KEY ]: true\n })\n this.overlay_.getSource().addFeature(this.arrowFeature_)\n }\n }\n\n /**\n * @private\n */\n resetAngleAndAnchor_() {\n this.resetAngle_();\n this.resetAnchor_();\n }\n\n /**\n * @private\n */\n resetAngle_() {\n this.set(ANGLE_PROP, 0, true);\n this.arrowFeature_ && this.arrowFeature_.set(ANGLE_PROP, this.getAngle());\n this.anchorFeature_ && this.anchorFeature_.set(ANGLE_PROP, this.getAngle());\n }\n\n /**\n * @private\n */\n resetAnchor_() {\n this.set(ANCHOR_PROP, getFeaturesCentroid(this.features_), true);\n\n if (this.getAnchor()) {\n this.arrowFeature_ && this.arrowFeature_.getGeometry().setCoordinates(this.getAnchor());\n this.anchorFeature_ && this.anchorFeature_.getGeometry().setCoordinates(this.getAnchor());\n }\n }\n\n /**\n * @private\n */\n onFeatureAdd_ () {\n this.resetAngleAndAnchor_()\n this.createOrUpdateAnchorFeature_()\n this.createOrUpdateArrowFeature_()\n }\n\n /**\n * @private\n */\n onFeatureRemove_ () {\n this.resetAngleAndAnchor_()\n\n if (this.features_.getLength()) {\n this.createOrUpdateAnchorFeature_()\n this.createOrUpdateArrowFeature_()\n } else {\n this.overlay_.getSource().clear()\n this.anchorFeature_ = this.arrowFeature_ = undefined\n }\n }\n\n /**\n * @private\n */\n onAngleChange_({ oldValue }) {\n this.features_.forEach(feature => feature.getGeometry().rotate(this.getAngle() - oldValue, this.getAnchor()))\n this.arrowFeature_ && this.arrowFeature_.set(ANGLE_PROP, this.getAngle())\n this.anchorFeature_ && this.anchorFeature_.set(ANGLE_PROP, this.getAngle())\n }\n\n /**\n * @private\n */\n onAnchorChange_() {\n const anchor = this.getAnchor()\n\n if (anchor) {\n this.anchorFeature_ && this.anchorFeature_.getGeometry().setCoordinates(anchor)\n this.arrowFeature_ && this.arrowFeature_.getGeometry().setCoordinates(anchor)\n }\n }\n\n /**\n * @param {ol.Collection} features\n * @private\n */\n dispatchRotateStartEvent_ (features) {\n this.dispatchEvent(\n new RotateFeatureEvent(\n RotateFeatureEventType.START,\n features,\n this.getAngle(),\n this.getAnchor()\n )\n )\n }\n\n /**\n * @param {ol.Collection} features\n * @private\n */\n dispatchRotatingEvent_ (features) {\n this.dispatchEvent(\n new RotateFeatureEvent(\n RotateFeatureEventType.ROTATING,\n features,\n this.getAngle(),\n this.getAnchor()\n )\n )\n }\n\n /**\n * @param {ol.Collection} features\n * @private\n */\n dispatchRotateEndEvent_ (features) {\n this.dispatchEvent(\n new RotateFeatureEvent(\n RotateFeatureEventType.END,\n features,\n this.getAngle(),\n this.getAnchor()\n )\n )\n }\n}\n\n/**\n * @param {ol.MapBrowserEvent} evt Map browser event.\n * @return {boolean} `false` to stop event propagation.\n * @this {RotateFeatureInteraction}\n * @private\n */\nfunction handleEvent (evt) {\n // disable selection of inner features\n const foundFeature = evt.map.forEachFeatureAtPixel(evt.pixel, identity)\n if (\n includes([ 'click', 'singleclick', 'dblclick' ], evt.type) &&\n includes([ this.anchorFeature_, this.arrowFeature_ ], foundFeature)\n ) {\n return false\n }\n\n return this::PointerInteraction.handleEvent(evt)\n}\n\n/**\n * @param {ol.MapBrowserEvent} evt Event.\n * @return {boolean}\n * @this {RotateFeatureInteraction}\n * @private\n */\nfunction handleDownEvent (evt) {\n const foundFeature = evt.map.forEachFeatureAtPixel(evt.pixel, identity)\n\n // handle click & drag on features for rotation\n if (\n foundFeature && !this.lastCoordinate_ &&\n (\n includes(this.features_.getArray(), foundFeature) ||\n foundFeature === this.arrowFeature_\n )\n ) {\n this.lastCoordinate_ = evt.coordinate\n\n this::handleMoveEvent(evt)\n this.dispatchRotateStartEvent_(this.features_)\n\n return true\n }\n // handle click & drag on rotation anchor feature\n else if (foundFeature && foundFeature === this.anchorFeature_) {\n this.anchorMoving_ = true\n this::handleMoveEvent(evt)\n\n return true\n }\n\n return false\n}\n\n/**\n * @param {ol.MapBrowserEvent} evt Event.\n * @return {boolean}\n * @this {RotateFeatureInteraction}\n * @private\n */\nfunction handleUpEvent (evt) {\n // stop drag sequence of features\n if (this.lastCoordinate_) {\n this.lastCoordinate_ = undefined\n\n this::handleMoveEvent(evt)\n this.dispatchRotateEndEvent_(this.features_)\n\n return true\n }\n // stop drag sequence of the anchors\n else if (this.anchorMoving_) {\n this.anchorMoving_ = false\n this::handleMoveEvent(evt)\n\n return true\n }\n\n return false\n}\n\n/**\n * @param {ol.MapBrowserEvent} evt Event.\n * @return {boolean}\n * @this {RotateFeatureInteraction}\n * @private\n */\nfunction handleDragEvent ({ coordinate }) {\n const anchorCoordinate = this.anchorFeature_.getGeometry().getCoordinates()\n\n // handle drag of features by angle\n if (this.lastCoordinate_) {\n // calculate vectors of last and current pointer positions\n const lastVector = [\n this.lastCoordinate_[ 0 ] - anchorCoordinate[ 0 ],\n this.lastCoordinate_[ 1 ] - anchorCoordinate[ 1 ]\n ]\n const newVector = [\n coordinate[ 0 ] - anchorCoordinate[ 0 ],\n coordinate[ 1 ] - anchorCoordinate[ 1 ]\n ]\n\n // calculate angle between last and current vectors (positive angle counter-clockwise)\n let angle = Math.atan2(\n lastVector[ 0 ] * newVector[ 1 ] - newVector[ 0 ] * lastVector[ 1 ],\n lastVector[ 0 ] * newVector[ 0 ] + lastVector[ 1 ] * newVector[ 1 ]\n )\n\n this.setAngle(this.getAngle() + angle)\n this.dispatchRotatingEvent_(this.features_)\n\n this.lastCoordinate_ = coordinate\n }\n // handle drag of the anchor\n else if (this.anchorMoving_) {\n this.setAnchor(coordinate)\n }\n}\n\n/**\n * @param {ol.MapBrowserEvent} evt Event.\n * @return {boolean}\n * @this {RotateFeatureInteraction}\n * @private\n */\nfunction handleMoveEvent ({ map, pixel }) {\n const elem = map.getTargetElement()\n const foundFeature = map.forEachFeatureAtPixel(pixel, identity)\n\n const setCursor = (cursor, vendor = false) => {\n if (vendor) {\n elem.style.cursor = '-webkit-' + cursor\n elem.style.cursor = '-moz-' + cursor\n }\n\n elem.style.cursor = cursor\n }\n\n if (this.lastCoordinate_) {\n this.previousCursor_ = elem.style.cursor\n setCursor('grabbing', true)\n } else if (\n foundFeature &&\n (\n includes(this.features_.getArray(), foundFeature) ||\n foundFeature === this.arrowFeature_\n )\n ) {\n this.previousCursor_ = elem.style.cursor\n setCursor('grab', true)\n } else if (( foundFeature && foundFeature === this.anchorFeature_ ) || this.anchorMoving_) {\n this.previousCursor_ = elem.style.cursor\n setCursor('crosshair')\n } else {\n setCursor(this.previousCursor_ || '')\n this.previousCursor_ = undefined\n }\n}\n\n/**\n * @returns {StyleFunction}\n * @private\n */\nfunction getDefaultStyle () {\n const white = [ 255, 255, 255, 0.8 ]\n const blue = [ 0, 153, 255, 0.8 ]\n const transparent = [ 255, 255, 255, 0.01 ]\n const width = 2\n\n const styles = {\n [ ANCHOR_KEY ]: [\n new Style({\n image: new RegularShape({\n fill: new Fill({\n color: [ 0, 153, 255, 0.8 ]\n }),\n stroke: new Stroke({\n color: blue,\n width: 1\n }),\n radius: 4,\n points: 6\n }),\n zIndex: Infinity\n })\n ],\n [ ARROW_KEY ]: [\n new Style({\n fill: new Fill({\n color: transparent\n }),\n stroke: new Stroke({\n color: white,\n width: width + 2\n }),\n text: new Text({\n font: '12px sans-serif',\n offsetX: 20,\n offsetY: -20,\n fill: new Fill({\n color: 'blue'\n }),\n stroke: new Stroke({\n color: white,\n width: width + 1\n })\n }),\n zIndex: Infinity\n }),\n new Style({\n fill: new Fill({\n color: transparent\n }),\n stroke: new Stroke({\n color: blue,\n width\n }),\n zIndex: Infinity\n })\n ]\n }\n\n return function (feature, resolution) {\n let style\n const angle = feature.get(ANGLE_PROP) || 0\n\n switch (true) {\n case feature.get(ANCHOR_KEY):\n style = styles[ ANCHOR_KEY ]\n style[ 0 ].getImage().setRotation(-angle)\n\n return style\n case feature.get(ARROW_KEY):\n style = styles[ ARROW_KEY ]\n\n const coordinates = feature.getGeometry().getCoordinates()\n // generate arrow polygon\n const geom = new Polygon([\n [\n [ coordinates[ 0 ], coordinates[ 1 ] - 6 * resolution ],\n [ coordinates[ 0 ] + 8 * resolution, coordinates[ 1 ] - 12 * resolution ],\n [ coordinates[ 0 ], coordinates[ 1 ] + 30 * resolution ],\n [ coordinates[ 0 ] - 8 * resolution, coordinates[ 1 ] - 12 * resolution ],\n [ coordinates[ 0 ], coordinates[ 1 ] - 6 * resolution ],\n ]\n ])\n\n // and rotate it according to current angle\n geom.rotate(angle, coordinates)\n style[ 0 ].setGeometry(geom)\n style[ 1 ].setGeometry(geom)\n style[ 0 ].getText().setText(Math.round(-angle * 180 / Math.PI) + '°')\n\n return style\n }\n }\n}\n\n/**\n * @param {ol.Collection|Array} features\n * @returns {ol.Extent | undefined}\n * @private\n */\nfunction getFeaturesExtent (features) {\n features = features instanceof Collection ? features.getArray() : features\n if (!features.length) return\n\n return new GeometryCollection(features.map(feature => feature.getGeometry())).getExtent()\n}\n\n/**\n * @param {ol.Collection | Array} features\n * @return {ol.Coordinate | undefined}\n */\nfunction getFeaturesCentroid (features) {\n features = features instanceof Collection ? features.getArray() : features\n if (!features.length) return\n\n return extentHelper.getCenter(getFeaturesExtent(features))\n}\n","/**\n * Rotate interaction for OpenLayers.\n * Allows vector feature rotation.\n *\n * @author Vladimir Vershinin \n * @licence MIT https://opensource.org/licenses/MIT\n * @copyright (c) 2016-2017, Vladimir Vershinin\n */\nimport RotateFeatureInteraction from \"./interaction\"\n\n// for backward compatibility\nif (typeof window !== 'undefined' && window.ol) {\n window.ol.interaction.RotateFeature = RotateFeatureInteraction\n}\n\nexport default RotateFeatureInteraction\n"],"names":["assert","condition","message","join","Error","identity","arg","includes","arr","value","indexOf","isArray","val","Object","prototype","toString","RotateFeatureEventType","RotateFeatureEvent","type","features","angle","anchor","propagationStopped_","type_","features_","angle_","anchor_","ANCHOR_KEY","ARROW_KEY","ANGLE_PROP","ANCHOR_PROP","RotateFeatureInteraction","options","handleEvent","handleDownEvent","handleUpEvent","handleDragEvent","handleMoveEvent","previousCursor_","undefined","anchorFeature_","arrowFeature_","lastCoordinate_","anchorMoving_","overlay_","VectorLayer","style","getDefaultStyle","VectorSource","Collection","setAnchor","getFeaturesCentroid","setAngle","on","onFeatureAdd_","onFeatureRemove_","onAngleChange_","onAnchorChange_","createOrUpdateAnchorFeature_","createOrUpdateArrowFeature_","map","setMap","active","isNaN","parseFloat","set","get","length","getAngle","getAnchor","getGeometry","setCoordinates","Feature","Point","getSource","addFeature","resetAngle_","resetAnchor_","resetAngleAndAnchor_","getLength","clear","oldValue","forEach","feature","rotate","dispatchEvent","START","ROTATING","END","getMap","setActive","getActive","PointerInteraction","evt","foundFeature","forEachFeatureAtPixel","pixel","getArray","coordinate","dispatchRotateStartEvent_","dispatchRotateEndEvent_","anchorCoordinate","getCoordinates","lastVector","newVector","Math","atan2","dispatchRotatingEvent_","elem","getTargetElement","setCursor","cursor","vendor","white","blue","transparent","width","styles","Style","RegularShape","Fill","Stroke","Infinity","Text","resolution","getImage","setRotation","coordinates","geom","Polygon","setGeometry","getText","setText","round","PI","getFeaturesExtent","GeometryCollection","getExtent","extentHelper","getCenter","window","ol","interaction","RotateFeature"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;AAKA,AAAO,SAASA,MAAT,CAAiBC,SAAjB,EAA0C;MAAdC,OAAc,u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,SAASyC,GAAT,CAAa;WAAWuB,QAAQb,WAAR,EAAX;GAAb,CAAvB,EAAuEmE,SAAvE,EAAP;;;;;;;AAOF,SAAStF,mBAAT,CAA8BhC,QAA9B,EAAwC;aAC3BA,oBAAoB8B,UAApB,GAAiC9B,SAAS8E,QAAT,EAAjC,GAAuD9E,QAAlE;MACI,CAACA,SAASgD,MAAd,EAAsB;;SAEfuE,aAAaC,SAAb,CAAuBJ,kBAAkBpH,QAAlB,CAAvB,CAAP;;;AChqBF;;;;;;;;AAQA,AAEA;AACA,IAAI,OAAOyH,MAAP,KAAkB,WAAlB,IAAiCA,OAAOC,EAA5C,EAAgD;SACvCA,EAAP,CAAUC,WAAV,CAAsBC,aAAtB,GAAsChH,wBAAtC;;;;;;;;;"} \ No newline at end of file diff --git a/dist/bundle.min.js b/dist/bundle.min.js deleted file mode 100644 index 482e596..0000000 --- a/dist/bundle.min.js +++ /dev/null @@ -1,2 +0,0 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("openlayers")):"function"==typeof define&&define.amd?define("ol-rotate-feature",["openlayers"],t):e.RotateFeatureInteraction=t(e.ol)}(this,function(e){"use strict";function t(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(t=["Assertion failed",t].join(": "),!e)throw new Error(t)}function r(e){return e}function o(e,t){return-1!==e.indexOf(t)}function n(e){return"[object Array]"===Object.prototype.toString.call(e)}e=e&&e.hasOwnProperty("default")?e.default:e;var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},s=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};i(this,r);var t,o,s,h,l,f=c(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,{handleEvent:R,handleDownEvent:U,handleUpEvent:I,handleDragEvent:T,handleMoveEvent:z}));if(f.previousCursor_=void 0,f.anchorFeature_=void 0,f.arrowFeature_=void 0,f.lastCoordinate_=void 0,f.anchorMoving_=!1,f.overlay_=new d({style:e.style||(o=[255,255,255,.8],s=[0,153,255,.8],h=[255,255,255,.01],u(t={},S,[new b({image:new k({fill:new E({color:[0,153,255,.8]}),stroke:new C({color:s,width:1}),radius:4,points:6}),zIndex:1/0})]),u(t,P,[new b({fill:new E({color:h}),stroke:new C({color:o,width:4}),text:new O({font:"12px sans-serif",offsetX:20,offsetY:-20,fill:new E({color:"blue"}),stroke:new C({color:o,width:3})}),zIndex:1/0}),new b({fill:new E({color:h}),stroke:new C({color:s,width:2}),zIndex:1/0})]),l=t,function(e,t){var r=void 0,o=e.get(M)||0;switch(!0){case e.get(S):return(r=l[S])[0].getImage().setRotation(-o),r;case e.get(P):r=l[P];var n=e.getGeometry().getCoordinates(),a=new F([[[n[0],n[1]-6*t],[n[0]+8*t,n[1]-12*t],[n[0],n[1]+30*t],[n[0]-8*t,n[1]-12*t],[n[0],n[1]-6*t]]]);return a.rotate(o,n),r[0].setGeometry(a),r[1].setGeometry(a),r[0].getText().setText(Math.round(180*-o/Math.PI)+"°"),r}}),source:new v({features:new y})}),f.features_=void 0,e.features)if(n(e.features))f.features_=new y(e.features);else{if(!(e.features instanceof y))throw new Error("Features option should be an array or collection of features, got "+a(e.features));f.features_=e.features}else f.features_=new y;return f.setAnchor(e.anchor||D(f.features_)),f.setAngle(e.angle||0),f.features_.on("add",f.onFeatureAdd_.bind(f)),f.features_.on("remove",f.onFeatureRemove_.bind(f)),f.on("change:"+M,f.onAngleChange_.bind(f)),f.on("change:"+j,f.onAnchorChange_.bind(f)),f.createOrUpdateAnchorFeature_(),f.createOrUpdateArrowFeature_(),f}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(r,p),s(r,[{key:"setMap",value:function(e){this.overlay_.setMap(e),h(r.prototype.__proto__||Object.getPrototypeOf(r.prototype),"setMap",this).call(this,e)}},{key:"setActive",value:function(e){this.overlay_&&this.overlay_.setMap(e?this.map:void 0),h(r.prototype.__proto__||Object.getPrototypeOf(r.prototype),"setActive",this).call(this,e)}},{key:"setAngle",value:function(e){t(!isNaN(parseFloat(e)),"Numeric value passed"),this.set(M,parseFloat(e))}},{key:"getAngle",value:function(){return this.get(M)}},{key:"setAnchor",value:function(e){t(null==e||n(e)&&2===e.length,"Array of two elements passed"),this.set(j,null!=e?e.map(parseFloat):D(this.features_))}},{key:"getAnchor",value:function(){return this.get(j)}},{key:"createOrUpdateAnchorFeature_",value:function(){var e,t=this.getAngle(),r=this.getAnchor();r&&(this.anchorFeature_?(this.anchorFeature_.getGeometry().setCoordinates(r),this.anchorFeature_.set(M,t)):(this.anchorFeature_=new w((e={geometry:new A(r)},u(e,M,t),u(e,S,!0),e)),this.overlay_.getSource().addFeature(this.anchorFeature_)))}},{key:"createOrUpdateArrowFeature_",value:function(){var e,t=this.getAngle(),r=this.getAnchor();r&&(this.arrowFeature_?(this.arrowFeature_.getGeometry().setCoordinates(r),this.arrowFeature_.set(M,t)):(this.arrowFeature_=new w((e={geometry:new A(r)},u(e,M,t),u(e,P,!0),e)),this.overlay_.getSource().addFeature(this.arrowFeature_)))}},{key:"resetAngleAndAnchor_",value:function(){this.resetAngle_(),this.resetAnchor_()}},{key:"resetAngle_",value:function(){this.set(M,0,!0),this.arrowFeature_&&this.arrowFeature_.set(M,this.getAngle()),this.anchorFeature_&&this.anchorFeature_.set(M,this.getAngle())}},{key:"resetAnchor_",value:function(){this.set(j,D(this.features_),!0),this.getAnchor()&&(this.arrowFeature_&&this.arrowFeature_.getGeometry().setCoordinates(this.getAnchor()),this.anchorFeature_&&this.anchorFeature_.getGeometry().setCoordinates(this.getAnchor()))}},{key:"onFeatureAdd_",value:function(){this.resetAngleAndAnchor_(),this.createOrUpdateAnchorFeature_(),this.createOrUpdateArrowFeature_()}},{key:"onFeatureRemove_",value:function(){this.resetAngleAndAnchor_(),this.features_.getLength()?(this.createOrUpdateAnchorFeature_(),this.createOrUpdateArrowFeature_()):(this.overlay_.getSource().clear(),this.anchorFeature_=this.arrowFeature_=void 0)}},{key:"onAngleChange_",value:function(e){var t=this,r=e.oldValue;this.features_.forEach(function(e){return e.getGeometry().rotate(t.getAngle()-r,t.getAnchor())}),this.arrowFeature_&&this.arrowFeature_.set(M,this.getAngle()),this.anchorFeature_&&this.anchorFeature_.set(M,this.getAngle())}},{key:"onAnchorChange_",value:function(){var e=this.getAnchor();e&&(this.anchorFeature_&&this.anchorFeature_.getGeometry().setCoordinates(e),this.arrowFeature_&&this.arrowFeature_.getGeometry().setCoordinates(e))}},{key:"dispatchRotateStartEvent_",value:function(e){this.dispatchEvent(new _(l,e,this.getAngle(),this.getAnchor()))}},{key:"dispatchRotatingEvent_",value:function(e){this.dispatchEvent(new _(f,e,this.getAngle(),this.getAnchor()))}},{key:"dispatchRotateEndEvent_",value:function(e){this.dispatchEvent(new _(g,e,this.getAngle(),this.getAnchor()))}},{key:"features",get:function(){return this.features_}},{key:"angle",get:function(){return this.getAngle()},set:function(e){this.setAngle(e)}},{key:"anchor",get:function(){return this.getAnchor()},set:function(e){this.setAnchor(e)}},{key:"map",set:function(e){this.setMap(e)},get:function(){return this.getMap()}},{key:"active",set:function(e){this.setActive(e)},get:function(){return this.getActive()}}]),r}();function R(e){var t=e.map.forEachFeatureAtPixel(e.pixel,r);return(!o(["click","singleclick","dblclick"],e.type)||!o([this.anchorFeature_,this.arrowFeature_],t))&&p.handleEvent.call(this,e)}function U(e){var t=e.map.forEachFeatureAtPixel(e.pixel,r);return!t||this.lastCoordinate_||!o(this.features_.getArray(),t)&&t!==this.arrowFeature_?!(!t||t!==this.anchorFeature_)&&(this.anchorMoving_=!0,z.call(this,e),!0):(this.lastCoordinate_=e.coordinate,z.call(this,e),this.dispatchRotateStartEvent_(this.features_),!0)}function I(e){return this.lastCoordinate_?(this.lastCoordinate_=void 0,z.call(this,e),this.dispatchRotateEndEvent_(this.features_),!0):!!this.anchorMoving_&&(this.anchorMoving_=!1,z.call(this,e),!0)}function T(e){var t=e.coordinate,r=this.anchorFeature_.getGeometry().getCoordinates();if(this.lastCoordinate_){var o=[this.lastCoordinate_[0]-r[0],this.lastCoordinate_[1]-r[1]],n=[t[0]-r[0],t[1]-r[1]],a=Math.atan2(o[0]*n[1]-n[0]*o[1],o[0]*n[0]+o[1]*n[1]);this.setAngle(this.getAngle()+a),this.dispatchRotatingEvent_(this.features_),this.lastCoordinate_=t}else this.anchorMoving_&&this.setAnchor(t)}function z(e){var t=e.map,n=e.pixel,a=t.getTargetElement(),i=t.forEachFeatureAtPixel(n,r),s=function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&(a.style.cursor="-webkit-"+e,a.style.cursor="-moz-"+e),a.style.cursor=e};this.lastCoordinate_?(this.previousCursor_=a.style.cursor,s("grabbing",!0)):i&&(o(this.features_.getArray(),i)||i===this.arrowFeature_)?(this.previousCursor_=a.style.cursor,s("grab",!0)):i&&i===this.anchorFeature_||this.anchorMoving_?(this.previousCursor_=a.style.cursor,s("crosshair")):(s(this.previousCursor_||""),this.previousCursor_=void 0)}function D(e){if((e=e instanceof y?e.getArray():e).length)return x.getCenter(function(e){if((e=e instanceof y?e.getArray():e).length)return new m(e.map(function(e){return e.getGeometry()})).getExtent()}(e))}return"undefined"!=typeof window&&window.ol&&(window.ol.interaction.RotateFeature=G),G}); -//# sourceMappingURL=bundle.min.js.map diff --git a/dist/bundle.min.js.map b/dist/bundle.min.js.map deleted file mode 100644 index c6125d0..0000000 --- a/dist/bundle.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"bundle.min.js","sources":["../src/util.js","../src/event.js","../src/interaction.js","../src/index.js"],"sourcesContent":["/**\n * @param {boolean} condition\n * @param {string} message\n * @throws Error\n */\nexport function assert (condition, message = '') {\n message = [ 'Assertion failed', message ].join(': ')\n\n if (!condition) {\n throw new Error(message)\n }\n}\n\n/**\n * @param {*} arg\n * @returns {*}\n */\nexport function identity (arg) {\n return arg\n}\n\n/**\n * @param {...*} args\n * @return {*}\n */\nexport function coalesce (...args) {\n return args.filter(value => value != null).shift()\n}\n\nconst counters = {}\n/**\n * @param {string} [prefix]\n * @return {number}\n */\nexport function uniqId (prefix = '') {\n const ns = prefix || 'default'\n counters[ ns ] = counters[ ns ] == null ? 0 : counters[ ns ]\n\n return String(prefix) + (++counters[ ns ])\n}\n\nexport function includes (arr, value) {\n return arr.indexOf(value) !== -1\n}\n\nexport function isArray (val) {\n return val::Object.prototype.toString() === '[object Array]'\n}\n","/**\n * @enum {string}\n */\nexport const RotateFeatureEventType = {\n /**\n * Triggered upon feature rotate start.\n * @event RotateFeatureEvent#rotatestart\n */\n START: 'rotatestart',\n /**\n * Triggered upon feature rotation.\n * @event RotateFeatureEvent#rotating\n */\n ROTATING: 'rotating',\n /**\n * Triggered upon feature rotation end.\n * @event RotateFeatureEvent#rotateend\n */\n END: 'rotateend'\n}\n\n/**\n * Events emitted by RotateFeatureInteraction instances are instances of this type.\n *\n * @class\n * @author Vladimir Vershinin\n */\nexport default class RotateFeatureEvent {\n /**\n * @param {string} type Type.\n * @param {ol.Collection} features Rotated features.\n * @param {number} angle Angle in radians.\n * @param {ol.Coordinate} anchor Anchor position.\n */\n constructor (type, features, angle, anchor) {\n /**\n * @type {boolean}\n * @private\n */\n this.propagationStopped_ = false\n\n /**\n * The event type.\n * @type {string}\n * @private\n */\n this.type_ = type\n\n /**\n * The features being rotated.\n * @type {ol.Collection}\n * @private\n */\n this.features_ = features\n /**\n * Current angle in radians.\n * @type {number}\n * @private\n */\n this.angle_ = angle\n /**\n * Current rotation anchor.\n * @type {ol.Coordinate}\n * @private\n */\n this.anchor_ = anchor\n }\n\n /**\n * @type {boolean}\n */\n get propagationStopped () {\n return this.propagationStopped_\n }\n\n /**\n * @type {RotateFeatureEventType}\n */\n get type () {\n return this.type_\n }\n\n /**\n * @type {ol.Collection}\n */\n get features () {\n return this.features_\n }\n\n /**\n * @type {number}\n */\n get angle () {\n return this.angle_\n }\n\n /**\n * @type {ol.Coordinate}\n */\n get anchor () {\n return this.anchor_\n }\n\n /**\n * Prevent event propagation.\n */\n preventDefault () {\n this.propagationStopped_ = true\n }\n\n /**\n * Stop event propagation.\n */\n stopPropagation () {\n this.propagationStopped_ = true\n }\n}\n","/**\n * Rotate interaction class.\n * Adds controls to rotate vector features.\n * Writes out total angle in radians (positive is counter-clockwise) to property for each feature.\n */\nimport PointerInteraction from 'ol/interaction/pointer'\nimport Collection from 'ol/collection'\nimport VectorLayer from 'ol/layer/vector'\nimport VectorSource from 'ol/source/vector'\nimport Feature from 'ol/feature'\nimport Point from 'ol/geom/point'\nimport Polygon from 'ol/geom/polygon'\nimport GeometryCollection from 'ol/geom/geometrycollection'\nimport Style from 'ol/style/style'\nimport RegularShape from 'ol/style/regularshape'\nimport Stroke from 'ol/style/stroke'\nimport Fill from 'ol/style/fill'\nimport Text from 'ol/style/text'\nimport extentHelper from 'ol/extent'\nimport { assert, identity, includes, isArray } from './util'\nimport RotateFeatureEvent, { RotateFeatureEventType } from './event'\n\nconst ANCHOR_KEY = 'rotate-anchor'\nconst ARROW_KEY = 'rotate-arrow'\n\nconst ANGLE_PROP = 'angle'\nconst ANCHOR_PROP = 'anchor'\n\n/**\n * @todo todo добавить опцию condition - для возможности переопределения клавиш\n */\nexport default class RotateFeatureInteraction extends PointerInteraction {\n /**\n * @param {InteractionOptions} options\n */\n constructor (options = {}) {\n super({\n handleEvent: handleEvent,\n handleDownEvent: handleDownEvent,\n handleUpEvent: handleUpEvent,\n handleDragEvent: handleDragEvent,\n handleMoveEvent: handleMoveEvent\n })\n /**\n * @type {string}\n * @private\n */\n this.previousCursor_ = undefined\n /**\n * @type {ol.Feature}\n * @private\n */\n this.anchorFeature_ = undefined\n /**\n * @type {ol.Feature}\n * @private\n */\n this.arrowFeature_ = undefined\n /**\n * @type {ol.Coordinate}\n * @private\n */\n this.lastCoordinate_ = undefined\n /**\n * @type {boolean}\n * @private\n */\n this.anchorMoving_ = false\n /**\n * @type {ol.layer.Vector}\n * @private\n */\n this.overlay_ = new VectorLayer({\n style: options.style || getDefaultStyle(),\n source: new VectorSource({\n features: new Collection()\n })\n })\n /**\n * @type {ol.Collection}\n * @private\n */\n this.features_ = undefined\n if (options.features) {\n if (isArray(options.features)) {\n this.features_ = new Collection(options.features)\n } else if (options.features instanceof Collection) {\n this.features_ = options.features\n } else {\n throw new Error('Features option should be an array or collection of features, ' +\n 'got ' + (typeof options.features))\n }\n } else {\n this.features_ = new Collection()\n }\n\n this.setAnchor(options.anchor || getFeaturesCentroid(this.features_))\n this.setAngle(options.angle || 0)\n\n this.features_.on('add', ::this.onFeatureAdd_)\n this.features_.on('remove', ::this.onFeatureRemove_)\n this.on('change:' + ANGLE_PROP, ::this.onAngleChange_)\n this.on('change:' + ANCHOR_PROP, ::this.onAnchorChange_)\n\n this.createOrUpdateAnchorFeature_()\n this.createOrUpdateArrowFeature_()\n }\n\n /**\n * @type {ol.Collection}\n */\n get features () {\n return this.features_\n }\n\n /**\n * @type {number}\n */\n get angle () {\n return this.getAngle()\n }\n\n /**\n * @param {number} angle\n */\n set angle (angle) {\n this.setAngle(angle)\n }\n\n /**\n * @type {ol.Coordinate|undefined}\n */\n get anchor () {\n return this.getAnchor()\n }\n\n /**\n * @param {ol.Coordinate|undefined} anchor\n */\n set anchor (anchor) {\n this.setAnchor(anchor)\n }\n\n /**\n * @param {ol.Map} map\n */\n set map (map) {\n this.setMap(map)\n }\n\n /**\n * @type {ol.Map}\n */\n get map() {\n return this.getMap()\n }\n\n /**\n * @param {boolean} active\n */\n set active (active) {\n this.setActive(active)\n }\n\n /**\n * @type {boolean}\n */\n get active () {\n return this.getActive()\n }\n\n /**\n * @param {ol.Map} map\n */\n setMap (map) {\n this.overlay_.setMap(map)\n super.setMap(map)\n }\n\n /**\n * @param {boolean} active\n */\n setActive (active) {\n if (this.overlay_) {\n this.overlay_.setMap(active ? this.map : undefined)\n }\n\n super.setActive(active)\n }\n\n /**\n * Set current angle of interaction features.\n *\n * @param {number} angle\n */\n setAngle (angle) {\n assert(!isNaN(parseFloat(angle)), 'Numeric value passed')\n\n this.set(ANGLE_PROP, parseFloat(angle))\n }\n\n /**\n * Returns current angle of interaction features.\n *\n * @return {number}\n */\n getAngle () {\n return this.get(ANGLE_PROP)\n }\n\n /**\n * Set current anchor position.\n *\n * @param {ol.Coordinate | undefined} anchor\n */\n setAnchor (anchor) {\n assert(anchor == null || isArray(anchor) && anchor.length === 2, 'Array of two elements passed')\n\n this.set(ANCHOR_PROP, anchor != null ? anchor.map(parseFloat) : getFeaturesCentroid(this.features_))\n }\n\n /**\n * Returns current anchor position.\n *\n * @return {ol.Coordinate | undefined}\n */\n getAnchor () {\n return this.get(ANCHOR_PROP)\n }\n\n /**\n * @private\n */\n createOrUpdateAnchorFeature_ () {\n const angle = this.getAngle()\n const anchor = this.getAnchor()\n\n if (!anchor) return\n\n if (this.anchorFeature_) {\n this.anchorFeature_.getGeometry().setCoordinates(anchor)\n this.anchorFeature_.set(ANGLE_PROP, angle)\n } else {\n this.anchorFeature_ = new Feature({\n geometry: new Point(anchor),\n [ ANGLE_PROP ]: angle,\n [ ANCHOR_KEY ]: true\n })\n this.overlay_.getSource().addFeature(this.anchorFeature_)\n }\n }\n\n /**\n * @private\n */\n createOrUpdateArrowFeature_ () {\n const angle = this.getAngle()\n const anchor = this.getAnchor()\n\n if (!anchor) return\n\n if (this.arrowFeature_) {\n this.arrowFeature_.getGeometry().setCoordinates(anchor)\n this.arrowFeature_.set(ANGLE_PROP, angle)\n } else {\n this.arrowFeature_ = new Feature({\n geometry: new Point(anchor),\n [ ANGLE_PROP ]: angle,\n [ ARROW_KEY ]: true\n })\n this.overlay_.getSource().addFeature(this.arrowFeature_)\n }\n }\n\n /**\n * @private\n */\n resetAngleAndAnchor_() {\n this.resetAngle_();\n this.resetAnchor_();\n }\n\n /**\n * @private\n */\n resetAngle_() {\n this.set(ANGLE_PROP, 0, true);\n this.arrowFeature_ && this.arrowFeature_.set(ANGLE_PROP, this.getAngle());\n this.anchorFeature_ && this.anchorFeature_.set(ANGLE_PROP, this.getAngle());\n }\n\n /**\n * @private\n */\n resetAnchor_() {\n this.set(ANCHOR_PROP, getFeaturesCentroid(this.features_), true);\n\n if (this.getAnchor()) {\n this.arrowFeature_ && this.arrowFeature_.getGeometry().setCoordinates(this.getAnchor());\n this.anchorFeature_ && this.anchorFeature_.getGeometry().setCoordinates(this.getAnchor());\n }\n }\n\n /**\n * @private\n */\n onFeatureAdd_ () {\n this.resetAngleAndAnchor_()\n this.createOrUpdateAnchorFeature_()\n this.createOrUpdateArrowFeature_()\n }\n\n /**\n * @private\n */\n onFeatureRemove_ () {\n this.resetAngleAndAnchor_()\n\n if (this.features_.getLength()) {\n this.createOrUpdateAnchorFeature_()\n this.createOrUpdateArrowFeature_()\n } else {\n this.overlay_.getSource().clear()\n this.anchorFeature_ = this.arrowFeature_ = undefined\n }\n }\n\n /**\n * @private\n */\n onAngleChange_({ oldValue }) {\n this.features_.forEach(feature => feature.getGeometry().rotate(this.getAngle() - oldValue, this.getAnchor()))\n this.arrowFeature_ && this.arrowFeature_.set(ANGLE_PROP, this.getAngle())\n this.anchorFeature_ && this.anchorFeature_.set(ANGLE_PROP, this.getAngle())\n }\n\n /**\n * @private\n */\n onAnchorChange_() {\n const anchor = this.getAnchor()\n\n if (anchor) {\n this.anchorFeature_ && this.anchorFeature_.getGeometry().setCoordinates(anchor)\n this.arrowFeature_ && this.arrowFeature_.getGeometry().setCoordinates(anchor)\n }\n }\n\n /**\n * @param {ol.Collection} features\n * @private\n */\n dispatchRotateStartEvent_ (features) {\n this.dispatchEvent(\n new RotateFeatureEvent(\n RotateFeatureEventType.START,\n features,\n this.getAngle(),\n this.getAnchor()\n )\n )\n }\n\n /**\n * @param {ol.Collection} features\n * @private\n */\n dispatchRotatingEvent_ (features) {\n this.dispatchEvent(\n new RotateFeatureEvent(\n RotateFeatureEventType.ROTATING,\n features,\n this.getAngle(),\n this.getAnchor()\n )\n )\n }\n\n /**\n * @param {ol.Collection} features\n * @private\n */\n dispatchRotateEndEvent_ (features) {\n this.dispatchEvent(\n new RotateFeatureEvent(\n RotateFeatureEventType.END,\n features,\n this.getAngle(),\n this.getAnchor()\n )\n )\n }\n}\n\n/**\n * @param {ol.MapBrowserEvent} evt Map browser event.\n * @return {boolean} `false` to stop event propagation.\n * @this {RotateFeatureInteraction}\n * @private\n */\nfunction handleEvent (evt) {\n // disable selection of inner features\n const foundFeature = evt.map.forEachFeatureAtPixel(evt.pixel, identity)\n if (\n includes([ 'click', 'singleclick', 'dblclick' ], evt.type) &&\n includes([ this.anchorFeature_, this.arrowFeature_ ], foundFeature)\n ) {\n return false\n }\n\n return this::PointerInteraction.handleEvent(evt)\n}\n\n/**\n * @param {ol.MapBrowserEvent} evt Event.\n * @return {boolean}\n * @this {RotateFeatureInteraction}\n * @private\n */\nfunction handleDownEvent (evt) {\n const foundFeature = evt.map.forEachFeatureAtPixel(evt.pixel, identity)\n\n // handle click & drag on features for rotation\n if (\n foundFeature && !this.lastCoordinate_ &&\n (\n includes(this.features_.getArray(), foundFeature) ||\n foundFeature === this.arrowFeature_\n )\n ) {\n this.lastCoordinate_ = evt.coordinate\n\n this::handleMoveEvent(evt)\n this.dispatchRotateStartEvent_(this.features_)\n\n return true\n }\n // handle click & drag on rotation anchor feature\n else if (foundFeature && foundFeature === this.anchorFeature_) {\n this.anchorMoving_ = true\n this::handleMoveEvent(evt)\n\n return true\n }\n\n return false\n}\n\n/**\n * @param {ol.MapBrowserEvent} evt Event.\n * @return {boolean}\n * @this {RotateFeatureInteraction}\n * @private\n */\nfunction handleUpEvent (evt) {\n // stop drag sequence of features\n if (this.lastCoordinate_) {\n this.lastCoordinate_ = undefined\n\n this::handleMoveEvent(evt)\n this.dispatchRotateEndEvent_(this.features_)\n\n return true\n }\n // stop drag sequence of the anchors\n else if (this.anchorMoving_) {\n this.anchorMoving_ = false\n this::handleMoveEvent(evt)\n\n return true\n }\n\n return false\n}\n\n/**\n * @param {ol.MapBrowserEvent} evt Event.\n * @return {boolean}\n * @this {RotateFeatureInteraction}\n * @private\n */\nfunction handleDragEvent ({ coordinate }) {\n const anchorCoordinate = this.anchorFeature_.getGeometry().getCoordinates()\n\n // handle drag of features by angle\n if (this.lastCoordinate_) {\n // calculate vectors of last and current pointer positions\n const lastVector = [\n this.lastCoordinate_[ 0 ] - anchorCoordinate[ 0 ],\n this.lastCoordinate_[ 1 ] - anchorCoordinate[ 1 ]\n ]\n const newVector = [\n coordinate[ 0 ] - anchorCoordinate[ 0 ],\n coordinate[ 1 ] - anchorCoordinate[ 1 ]\n ]\n\n // calculate angle between last and current vectors (positive angle counter-clockwise)\n let angle = Math.atan2(\n lastVector[ 0 ] * newVector[ 1 ] - newVector[ 0 ] * lastVector[ 1 ],\n lastVector[ 0 ] * newVector[ 0 ] + lastVector[ 1 ] * newVector[ 1 ]\n )\n\n this.setAngle(this.getAngle() + angle)\n this.dispatchRotatingEvent_(this.features_)\n\n this.lastCoordinate_ = coordinate\n }\n // handle drag of the anchor\n else if (this.anchorMoving_) {\n this.setAnchor(coordinate)\n }\n}\n\n/**\n * @param {ol.MapBrowserEvent} evt Event.\n * @return {boolean}\n * @this {RotateFeatureInteraction}\n * @private\n */\nfunction handleMoveEvent ({ map, pixel }) {\n const elem = map.getTargetElement()\n const foundFeature = map.forEachFeatureAtPixel(pixel, identity)\n\n const setCursor = (cursor, vendor = false) => {\n if (vendor) {\n elem.style.cursor = '-webkit-' + cursor\n elem.style.cursor = '-moz-' + cursor\n }\n\n elem.style.cursor = cursor\n }\n\n if (this.lastCoordinate_) {\n this.previousCursor_ = elem.style.cursor\n setCursor('grabbing', true)\n } else if (\n foundFeature &&\n (\n includes(this.features_.getArray(), foundFeature) ||\n foundFeature === this.arrowFeature_\n )\n ) {\n this.previousCursor_ = elem.style.cursor\n setCursor('grab', true)\n } else if (( foundFeature && foundFeature === this.anchorFeature_ ) || this.anchorMoving_) {\n this.previousCursor_ = elem.style.cursor\n setCursor('crosshair')\n } else {\n setCursor(this.previousCursor_ || '')\n this.previousCursor_ = undefined\n }\n}\n\n/**\n * @returns {StyleFunction}\n * @private\n */\nfunction getDefaultStyle () {\n const white = [ 255, 255, 255, 0.8 ]\n const blue = [ 0, 153, 255, 0.8 ]\n const transparent = [ 255, 255, 255, 0.01 ]\n const width = 2\n\n const styles = {\n [ ANCHOR_KEY ]: [\n new Style({\n image: new RegularShape({\n fill: new Fill({\n color: [ 0, 153, 255, 0.8 ]\n }),\n stroke: new Stroke({\n color: blue,\n width: 1\n }),\n radius: 4,\n points: 6\n }),\n zIndex: Infinity\n })\n ],\n [ ARROW_KEY ]: [\n new Style({\n fill: new Fill({\n color: transparent\n }),\n stroke: new Stroke({\n color: white,\n width: width + 2\n }),\n text: new Text({\n font: '12px sans-serif',\n offsetX: 20,\n offsetY: -20,\n fill: new Fill({\n color: 'blue'\n }),\n stroke: new Stroke({\n color: white,\n width: width + 1\n })\n }),\n zIndex: Infinity\n }),\n new Style({\n fill: new Fill({\n color: transparent\n }),\n stroke: new Stroke({\n color: blue,\n width\n }),\n zIndex: Infinity\n })\n ]\n }\n\n return function (feature, resolution) {\n let style\n const angle = feature.get(ANGLE_PROP) || 0\n\n switch (true) {\n case feature.get(ANCHOR_KEY):\n style = styles[ ANCHOR_KEY ]\n style[ 0 ].getImage().setRotation(-angle)\n\n return style\n case feature.get(ARROW_KEY):\n style = styles[ ARROW_KEY ]\n\n const coordinates = feature.getGeometry().getCoordinates()\n // generate arrow polygon\n const geom = new Polygon([\n [\n [ coordinates[ 0 ], coordinates[ 1 ] - 6 * resolution ],\n [ coordinates[ 0 ] + 8 * resolution, coordinates[ 1 ] - 12 * resolution ],\n [ coordinates[ 0 ], coordinates[ 1 ] + 30 * resolution ],\n [ coordinates[ 0 ] - 8 * resolution, coordinates[ 1 ] - 12 * resolution ],\n [ coordinates[ 0 ], coordinates[ 1 ] - 6 * resolution ],\n ]\n ])\n\n // and rotate it according to current angle\n geom.rotate(angle, coordinates)\n style[ 0 ].setGeometry(geom)\n style[ 1 ].setGeometry(geom)\n style[ 0 ].getText().setText(Math.round(-angle * 180 / Math.PI) + '°')\n\n return style\n }\n }\n}\n\n/**\n * @param {ol.Collection|Array} features\n * @returns {ol.Extent | undefined}\n * @private\n */\nfunction getFeaturesExtent (features) {\n features = features instanceof Collection ? features.getArray() : features\n if (!features.length) return\n\n return new GeometryCollection(features.map(feature => feature.getGeometry())).getExtent()\n}\n\n/**\n * @param {ol.Collection | Array} features\n * @return {ol.Coordinate | undefined}\n */\nfunction getFeaturesCentroid (features) {\n features = features instanceof Collection ? features.getArray() : features\n if (!features.length) return\n\n return extentHelper.getCenter(getFeaturesExtent(features))\n}\n","/**\n * Rotate interaction for OpenLayers.\n * Allows vector feature rotation.\n *\n * @author Vladimir Vershinin \n * @licence MIT https://opensource.org/licenses/MIT\n * @copyright (c) 2016-2017, Vladimir Vershinin\n */\nimport RotateFeatureInteraction from \"./interaction\"\n\n// for backward compatibility\nif (typeof window !== 'undefined' && window.ol) {\n window.ol.interaction.RotateFeature = RotateFeatureInteraction\n}\n\nexport default RotateFeatureInteraction\n"],"names":["assert","condition","message","join","Error","identity","arg","includes","arr","value","indexOf","isArray","val","Object","prototype","toString","RotateFeatureEventType","RotateFeatureEvent","type","features","angle","anchor","propagationStopped_","type_","features_","angle_","anchor_","this","ANCHOR_KEY","ARROW_KEY","ANGLE_PROP","ANCHOR_PROP","RotateFeatureInteraction","options","white","blue","transparent","styles","handleEvent","handleDownEvent","handleUpEvent","handleDragEvent","handleMoveEvent","previousCursor_","undefined","anchorFeature_","arrowFeature_","lastCoordinate_","anchorMoving_","overlay_","VectorLayer","style","Style","RegularShape","Fill","Stroke","Infinity","width","Text","feature","resolution","get","getImage","setRotation","coordinates","getGeometry","getCoordinates","geom","Polygon","rotate","setGeometry","getText","setText","Math","round","PI","VectorSource","Collection","setAnchor","getFeaturesCentroid","_this","setAngle","on","onFeatureAdd_","onFeatureRemove_","onAngleChange_","onAnchorChange_","createOrUpdateAnchorFeature_","createOrUpdateArrowFeature_","PointerInteraction","map","setMap","active","isNaN","parseFloat","set","length","getAngle","getAnchor","setCoordinates","Feature","Point","getSource","addFeature","resetAngle_","resetAnchor_","resetAngleAndAnchor_","getLength","clear","oldValue","forEach","_this2","dispatchEvent","getMap","setActive","getActive","evt","foundFeature","forEachFeatureAtPixel","pixel","getArray","coordinate","dispatchRotateStartEvent_","dispatchRotateEndEvent_","anchorCoordinate","lastVector","newVector","atan2","dispatchRotatingEvent_","elem","getTargetElement","setCursor","cursor","extentHelper","getCenter","GeometryCollection","getExtent","getFeaturesExtent","window","ol","interaction","RotateFeature"],"mappings":"iQAKA,SAAgBA,EAAQC,OAAWC,yDAAU,SAC/B,mBAAoBA,GAAUC,KAAK,OAE1CF,QACG,IAAIG,MAAMF,GAQpB,SAAgBG,EAAUC,UACjBA,EAuBT,SAAgBC,EAAUC,EAAKC,UACE,IAAxBD,EAAIE,QAAQD,GAGrB,SAAgBE,EAASC,SACqB,mBAAhCC,OAAOC,UAAUC,2nCC3ClBC,EAKJ,cALIA,EAUD,WAVCA,EAeN,YAScC,wBAONC,EAAMC,EAAUC,EAAOC,kBAK7BC,qBAAsB,OAOtBC,MAAQL,OAORM,UAAYL,OAMZM,OAASL,OAMTM,QAAUL,0DA0CVC,qBAAsB,iDAOtBA,qBAAsB,oDA1CpBK,KAAKL,wDAOLK,KAAKJ,8CAOLI,KAAKH,+CAOLG,KAAKF,6CAOLE,KAAKD,oQC9EVE,EAAa,gBACbC,EAAY,eAEZC,EAAa,QACbC,EAAc,SAKCC,+BAINC,4EA2gBPC,EACAC,EACAC,EAGAC,0EA9gBWC,kBACIC,gBACFC,kBACEC,kBACAC,UAMdC,qBAAkBC,IAKlBC,oBAAiBD,IA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AGhB9F,KAAKqB,oBACP8B,UAAU2C,GAUnB,SAAS/E,SAAmBgD,IAAAA,IAAK6B,IAAAA,MACzBU,EAAOvC,EAAIwC,mBACXb,EAAe3B,EAAI4B,sBAAsBC,EAAOlH,GAEhD8H,EAAY,SAACC,+DAEVjF,MAAMiF,OAAS,WAAaA,IAC5BjF,MAAMiF,OAAS,QAAUA,KAG3BjF,MAAMiF,OAASA,GAGlBzG,KAAKoB,sBACFJ,gBAAkBsF,EAAK9E,MAAMiF,SACxB,YAAY,IAEtBf,IAEE9G,EAASoB,KAAKH,UAAUgG,WAAYH,IACpCA,IAAiB1F,KAAKmB,qBAGnBH,gBAAkBsF,EAAK9E,MAAMiF,SACxB,QAAQ,IACPf,GAAgBA,IAAiB1F,KAAKkB,gBAAoBlB,KAAKqB,oBACrEL,gBAAkBsF,EAAK9E,MAAMiF,SACxB,iBAEAzG,KAAKgB,iBAAmB,SAC7BA,qBAAkBC,GAuH3B,SAASmC,EAAqB5D,SACjBA,aAAoB0D,EAAa1D,EAASqG,WAAarG,GACpD6E,cAEPqC,EAAaC,UAftB,SAA4BnH,SACfA,aAAoB0D,EAAa1D,EAASqG,WAAarG,GACpD6E,cAEP,IAAIuC,EAAmBpH,EAASuE,IAAI,mBAAW/B,EAAQM,iBAAgBuE,YAWhDC,CAAkBtH,UCrpB5B,oBAAXuH,QAA0BA,OAAOC,YACnCA,GAAGC,YAAYC,cAAgB7G"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 879277b..24787cc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ol-rotate-feature", - "version": "1.3.0", + "version": "1.4.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 642c570..1375af5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ol-rotate-feature", - "version": "1.3.0", + "version": "1.4.0", "description": "Rotate vector features interaction for OpenLayers", "main": "dist/bundle.js", "module": "dist/bundle.es.js",