kepler.gl
Version:
kepler.gl is a webgl based application to visualize large scale location data in the browser
59 lines (57 loc) • 8.61 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ModifyModeExtended = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _editModes = require("@nebula.gl/edit-modes");
var _constants = require("@kepler.gl/constants");
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
function _superPropGet(t, e, r, o) { var p = (0, _get2["default"])((0, _getPrototypeOf2["default"])(1 & o ? t.prototype : t), e, r); return 2 & o ? function (t) { return p.apply(r, t); } : p; } // SPDX-License-Identifier: MIT
// Copyright contributors to the kepler.gl project
var RIGHT_BUTTON = 2;
/**
* Show helper only when the point is close enough to the line.
*/
var ModifyModeExtended = exports.ModifyModeExtended = /*#__PURE__*/function (_ModifyMode) {
function ModifyModeExtended() {
(0, _classCallCheck2["default"])(this, ModifyModeExtended);
return _callSuper(this, ModifyModeExtended, arguments);
}
(0, _inherits2["default"])(ModifyModeExtended, _ModifyMode);
return (0, _createClass2["default"])(ModifyModeExtended, [{
key: "getNearestPoint",
value:
// @ts-expect-error expect to return no point when object is too far
function getNearestPoint(line, inPoint, viewport) {
var p = _superPropGet(ModifyModeExtended, "getNearestPoint", this, 3)([line, inPoint, viewport]);
if (p && viewport) {
var p1 = viewport.project(p.geometry.coordinates);
var p2 = viewport.project(inPoint.geometry.coordinates);
var d = Math.sqrt(Math.pow(p1[0] - p2[0], 2) + Math.pow(p1[1] - p2[1], 2));
if (d > _constants.EDITOR_LAYER_PICKING_RADIUS) {
return;
}
}
return p;
}
}, {
key: "handleClick",
value: function handleClick(event, props) {
var _event$sourceEvent;
// prevent insertion of points for right click
if ((event === null || event === void 0 || (_event$sourceEvent = event.sourceEvent) === null || _event$sourceEvent === void 0 ? void 0 : _event$sourceEvent.button) === RIGHT_BUTTON) {
return;
}
_superPropGet(ModifyModeExtended, "handleClick", this, 3)([event, props]);
}
}]);
}(_editModes.ModifyMode);
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJfZWRpdE1vZGVzIiwicmVxdWlyZSIsIl9jb25zdGFudHMiLCJfY2FsbFN1cGVyIiwidCIsIm8iLCJlIiwiX2dldFByb3RvdHlwZU9mMiIsIl9wb3NzaWJsZUNvbnN0cnVjdG9yUmV0dXJuMiIsIl9pc05hdGl2ZVJlZmxlY3RDb25zdHJ1Y3QiLCJSZWZsZWN0IiwiY29uc3RydWN0IiwiY29uc3RydWN0b3IiLCJhcHBseSIsIkJvb2xlYW4iLCJwcm90b3R5cGUiLCJ2YWx1ZU9mIiwiY2FsbCIsIl9zdXBlclByb3BHZXQiLCJyIiwicCIsIl9nZXQyIiwiUklHSFRfQlVUVE9OIiwiTW9kaWZ5TW9kZUV4dGVuZGVkIiwiZXhwb3J0cyIsIl9Nb2RpZnlNb2RlIiwiX2NsYXNzQ2FsbENoZWNrMiIsImFyZ3VtZW50cyIsIl9pbmhlcml0czIiLCJfY3JlYXRlQ2xhc3MyIiwia2V5IiwidmFsdWUiLCJnZXROZWFyZXN0UG9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