@wayz/react-gl
Version:
React Component for DeckGL, Base on AMap, Mapbox GL
89 lines (88 loc) • 4.29 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) {
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 { CompositeLayer } from '@deck.gl/core';
import { PolygonLayer } from '@deck.gl/layers';
import { getGeoHashPolygon } from './geohash-util';
var defaultProps = __assign(__assign({}, PolygonLayer.defaultProps), { getGeoHash: { type: 'accessor', value: function (d) { return d.geohash; } } });
var GeoHashLayer = /** @class */ (function (_super) {
__extends(GeoHashLayer, _super);
function GeoHashLayer() {
return _super !== null && _super.apply(this, arguments) || this;
}
GeoHashLayer.prototype.renderLayers = function () {
// Layer prop
var _a = this.props, data = _a.data, getGeoHash = _a.getGeoHash;
// Rendering props underlying layer
var _b = this.props, elevationScale = _b.elevationScale, extruded = _b.extruded, wireframe = _b.wireframe, filled = _b.filled, stroked = _b.stroked, lineWidthUnits = _b.lineWidthUnits, lineWidthScale = _b.lineWidthScale, lineWidthMinPixels = _b.lineWidthMinPixels, lineWidthMaxPixels = _b.lineWidthMaxPixels, lineJointRounded = _b.lineJointRounded, lineMiterLimit = _b.lineMiterLimit, getElevation = _b.getElevation, getFillColor = _b.getFillColor, getLineColor = _b.getLineColor, getLineWidth = _b.getLineWidth,
//@ts-ignore
lineDashJustified = _b.lineDashJustified,
//@ts-ignore
getLineDashArray = _b.getLineDashArray;
// Accessor props for underlying layers
var _c = this.props, updateTriggers = _c.updateTriggers, material = _c.material;
// Filled Polygon Layer
var CellLayer = this.getSubLayerClass('cell', PolygonLayer);
return new CellLayer({
filled: filled,
wireframe: wireframe,
extruded: extruded,
elevationScale: elevationScale,
stroked: stroked,
lineWidthUnits: lineWidthUnits,
lineWidthScale: lineWidthScale,
lineWidthMinPixels: lineWidthMinPixels,
lineWidthMaxPixels: lineWidthMaxPixels,
lineJointRounded: lineJointRounded,
lineMiterLimit: lineMiterLimit,
lineDashJustified: lineDashJustified,
material: material,
getElevation: getElevation,
getFillColor: getFillColor,
getLineColor: getLineColor,
getLineWidth: getLineWidth,
getLineDashArray: getLineDashArray,
}, this.getSubLayerProps({
id: 'cell',
updateTriggers: {
getElevation: updateTriggers.getElevation,
getFillColor: updateTriggers.getFillColor,
getLineColor: updateTriggers.getLineColor,
getLineWidth: updateTriggers.getLineWidth,
getLineDashArray: updateTriggers.getLineDashArray,
},
}), {
data: data,
// _normalize: false,
positionFormat: 'XY',
getPolygon: function (x) { return getGeoHashPolygon(getGeoHash(x)); },
});
};
return GeoHashLayer;
}(CompositeLayer));
GeoHashLayer.layerName = 'GeoHashLayer';
GeoHashLayer.defaultProps = defaultProps;
export default GeoHashLayer;