UNPKG

@wayz/react-gl

Version:

React Component for DeckGL, Base on AMap, Mapbox GL

118 lines (117 loc) 5.78 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) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; import { ArcLayer } from '@deck.gl/layers'; import { CompositeLayer } from '@deck.gl/core'; import AnimatedArcLayer from '../animate-arc-layer/animate-arc-layer'; var DEFAULT_COLOR = [250, 226, 255, 255]; var defaultProps = __assign(__assign({}, AnimatedArcLayer.defaultProps), { // color of the source pulse getPulseSourceColor: { type: 'accessor', value: DEFAULT_COLOR }, // color of the target pulse getPulseTargetColor: { type: 'accessor', value: DEFAULT_COLOR }, // Width of the blob getPulseWidth: { type: 'accessor', min: 0, value: 1 } }); var PulseArcLayer = /** @class */ (function (_super) { __extends(PulseArcLayer, _super); function PulseArcLayer() { return _super !== null && _super.apply(this, arguments) || this; } PulseArcLayer.prototype.renderLayers = function () { // Layer prop var data = this.props.data; // Rendering props underlying layer var _a = this.props, // @ts-ignore greatCircle = _a.greatCircle, widthUnits = _a.widthUnits, widthMaxPixels = _a.widthMaxPixels, widthMinPixels = _a.widthMinPixels, widthScale = _a.widthScale, animationSpeed = _a.animationSpeed, tailLength = _a.tailLength; // Accessor props for underlying layers var _b = this.props, updateTriggers = _b.updateTriggers, getSourceColor = _b.getSourceColor, getTargetColor = _b.getTargetColor, getSourcePosition = _b.getSourcePosition, getTargetPosition = _b.getTargetPosition, getPulseSourceColor = _b.getPulseSourceColor, getPulseTargetColor = _b.getPulseTargetColor, getWidth = _b.getWidth, getHeight = _b.getHeight, getTilt = _b.getTilt, getFrequency = _b.getFrequency, getPulseWidth = _b.getPulseWidth; var LinkArcLayer = this.getSubLayerClass('link-arc', ArcLayer); var PulseArcLayer = this.getSubLayerClass('pulse-arc', AnimatedArcLayer); return [ new LinkArcLayer({ greatCircle: greatCircle, widthUnits: widthUnits, widthMaxPixels: widthMaxPixels, widthMinPixels: widthMinPixels, widthScale: widthScale, getSourceColor: getSourceColor, getTargetColor: getTargetColor, getSourcePosition: getSourcePosition, getTargetPosition: getTargetPosition, getWidth: getWidth, getHeight: getHeight, getTilt: getTilt, }, this.getSubLayerProps({ id: 'link-arc', updateTriggers: { getSourceColor: updateTriggers.getSourceColor, getTargetColor: updateTriggers.getTargetColor, getSourcePosition: updateTriggers.getSourcePosition, getTargetPosition: updateTriggers.getTargetPosition, getWidth: updateTriggers.getWidth, getTilt: updateTriggers.getTilt, }, }), { data: data, }), new PulseArcLayer({ greatCircle: greatCircle, widthUnits: widthUnits, widthMaxPixels: widthMaxPixels, widthMinPixels: widthMinPixels, widthScale: widthScale, animationSpeed: animationSpeed, tailLength: tailLength, getSourcePosition: getSourcePosition, getTargetPosition: getTargetPosition, getHeight: getHeight, getTilt: getTilt, getFrequency: getFrequency, }, this.getSubLayerProps({ id: 'pulse-arc', updateTriggers: { getSourceColor: updateTriggers.getSourceColor, getTargetColor: updateTriggers.getTargetColor, getSourcePosition: updateTriggers.getSourcePosition, getTargetPosition: updateTriggers.getTargetPosition, getWidth: updateTriggers.getWidth, getTilt: updateTriggers.getTilt, getFrequency: updateTriggers.getFrequency, }, }), { data: data, getWidth: this.getSubLayerAccessor(getPulseWidth), getSourceColor: this.getSubLayerAccessor(getPulseSourceColor), getTargetColor: this.getSubLayerAccessor(getPulseTargetColor), }), ]; }; return PulseArcLayer; }(CompositeLayer)); PulseArcLayer.layerName = 'PulseArcLayer'; PulseArcLayer.defaultProps = defaultProps; export default PulseArcLayer;