@qn-pandora/pandora-visualization
Version:
Pandora 通用可视化库
128 lines (127 loc) • 6.83 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importDefault(require("react"));
var lodash_1 = require("lodash");
var mobx_react_1 = require("mobx-react");
var bind_1 = __importDefault(require("../../../../utils/bind"));
var Base_1 = require("../../../../components/Base");
var BasicComponent_1 = __importDefault(require("../../../../components/Base/BasicComponent"));
var services_1 = require("../../../../services");
var type_1 = require("../../../../constants/language/mapbox/type");
var Common_1 = require("../../../Common");
var utils_1 = require("../utils");
var constants_1 = require("../constants");
var Item = Common_1.Form.Item;
var MapConfig = /** @class */ (function (_super) {
__extends(MapConfig, _super);
function MapConfig() {
return _super !== null && _super.apply(this, arguments) || this;
}
MapConfig.prototype.onZoomChange = function (value) {
var setZoom = this.props.chartStyleService.setZoom;
setZoom([value]);
};
MapConfig.prototype.onCenterLongChange = function (value) {
var _a = this.props.chartStyleService, center = _a.center, setCenter = _a.setCenter;
setCenter([value, center[1]]);
};
MapConfig.prototype.onCenterLatChange = function (value) {
var _a = this.props.chartStyleService, center = _a.center, setCenter = _a.setCenter;
setCenter([center[0], value]);
};
MapConfig.prototype.zoomValidator = function (value) {
var maxZoom = this.props.chartStyleService.maxZoom;
return Promise.all([
utils_1.numberValidator(value),
utils_1.rangeValidator(value, 0, maxZoom)
]).then(lodash_1.noop);
};
MapConfig.prototype.longitudeValidator = function (value) {
return Promise.all([
utils_1.numberValidator(value),
utils_1.rangeValidator(value, -180, 180)
]).then(lodash_1.noop);
};
MapConfig.prototype.latitudeValidator = function (value) {
return Promise.all([
utils_1.numberValidator(value),
utils_1.rangeValidator(value, -90, 90)
]).then(lodash_1.noop);
};
MapConfig.prototype.render = function () {
var _a = this.props.chartStyleService, center = _a.center, maxZoom = _a.maxZoom, zoom = _a.zoom, coordinateSystem = _a.coordinateSystem, setCoordinateSystem = _a.setCoordinateSystem;
return (react_1.default.createElement("div", null,
react_1.default.createElement(Base_1.SolidRadioItem, { label: services_1.formatString(type_1.MapboxLocale.coordinateSystemTitle), getPopupContainer: this.getRootDOM, options: constants_1.CoordinateSystems, value: coordinateSystem, onChange: setCoordinateSystem }),
react_1.default.createElement(Base_1.NumberItem, { min: 0, max: maxZoom, onValidate: this.zoomValidator, label: services_1.formatString(type_1.MapboxLocale.config.zoom), value: zoom[0], onChange: this.onZoomChange }),
react_1.default.createElement(Item, { label: services_1.formatString(type_1.MapboxLocale.config.center) },
react_1.default.createElement(Common_1.WithValidatorInputNumber, { min: -180, max: 180, onValidate: this.longitudeValidator, placeholder: services_1.formatString(type_1.MapboxLocale.longitude), value: center[0], onChange: this.onCenterLongChange })),
react_1.default.createElement(Item, { label: react_1.default.createElement("span", null) },
react_1.default.createElement(Common_1.WithValidatorInputNumber, { min: -90, max: 90, onValidate: this.latitudeValidator, placeholder: services_1.formatString(type_1.MapboxLocale.latitude), value: center[1], onChange: this.onCenterLatChange }))));
};
__decorate([
bind_1.default,
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number]),
__metadata("design:returntype", void 0)
], MapConfig.prototype, "onZoomChange", null);
__decorate([
bind_1.default,
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number]),
__metadata("design:returntype", void 0)
], MapConfig.prototype, "onCenterLongChange", null);
__decorate([
bind_1.default,
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number]),
__metadata("design:returntype", void 0)
], MapConfig.prototype, "onCenterLatChange", null);
__decorate([
bind_1.default,
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], MapConfig.prototype, "zoomValidator", null);
__decorate([
bind_1.default,
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], MapConfig.prototype, "longitudeValidator", null);
__decorate([
bind_1.default,
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], MapConfig.prototype, "latitudeValidator", null);
MapConfig = __decorate([
mobx_react_1.observer
], MapConfig);
return MapConfig;
}(BasicComponent_1.default));
exports.default = MapConfig;