UNPKG

@qn-pandora/pandora-visualization

Version:

Pandora 通用可视化库

123 lines (122 loc) 6.25 kB
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); }; import React from 'react'; import { noop } from 'lodash'; import { observer } from 'mobx-react'; import bind from '../../../../utils/bind'; import { NumberItem, SolidRadioItem } from '../../../../components/Base'; import BasicComponent from '../../../../components/Base/BasicComponent'; import { formatString } from '../../../../services'; import { MapboxLocale } from '../../../../constants/language/mapbox/type'; import { Form, WithValidatorInputNumber } from '../../../Common'; import { numberValidator, rangeValidator } from '../utils'; import { CoordinateSystems } from '../constants'; var Item = 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([ numberValidator(value), rangeValidator(value, 0, maxZoom) ]).then(noop); }; MapConfig.prototype.longitudeValidator = function (value) { return Promise.all([ numberValidator(value), rangeValidator(value, -180, 180) ]).then(noop); }; MapConfig.prototype.latitudeValidator = function (value) { return Promise.all([ numberValidator(value), rangeValidator(value, -90, 90) ]).then(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.createElement("div", null, React.createElement(SolidRadioItem, { label: formatString(MapboxLocale.coordinateSystemTitle), getPopupContainer: this.getRootDOM, options: CoordinateSystems, value: coordinateSystem, onChange: setCoordinateSystem }), React.createElement(NumberItem, { min: 0, max: maxZoom, onValidate: this.zoomValidator, label: formatString(MapboxLocale.config.zoom), value: zoom[0], onChange: this.onZoomChange }), React.createElement(Item, { label: formatString(MapboxLocale.config.center) }, React.createElement(WithValidatorInputNumber, { min: -180, max: 180, onValidate: this.longitudeValidator, placeholder: formatString(MapboxLocale.longitude), value: center[0], onChange: this.onCenterLongChange })), React.createElement(Item, { label: React.createElement("span", null) }, React.createElement(WithValidatorInputNumber, { min: -90, max: 90, onValidate: this.latitudeValidator, placeholder: formatString(MapboxLocale.latitude), value: center[1], onChange: this.onCenterLatChange })))); }; __decorate([ bind, __metadata("design:type", Function), __metadata("design:paramtypes", [Number]), __metadata("design:returntype", void 0) ], MapConfig.prototype, "onZoomChange", null); __decorate([ bind, __metadata("design:type", Function), __metadata("design:paramtypes", [Number]), __metadata("design:returntype", void 0) ], MapConfig.prototype, "onCenterLongChange", null); __decorate([ bind, __metadata("design:type", Function), __metadata("design:paramtypes", [Number]), __metadata("design:returntype", void 0) ], MapConfig.prototype, "onCenterLatChange", null); __decorate([ bind, __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], MapConfig.prototype, "zoomValidator", null); __decorate([ bind, __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], MapConfig.prototype, "longitudeValidator", null); __decorate([ bind, __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], MapConfig.prototype, "latitudeValidator", null); MapConfig = __decorate([ observer ], MapConfig); return MapConfig; }(BasicComponent)); export default MapConfig;