@deck.gl/arcgis
Version:
Use deck.gl as a custom ArcGIS API for JavaScript layer
65 lines (56 loc) • 1.32 kB
text/typescript
// deck.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
const properties = {
layers: {},
layerFilter: {},
parameters: {},
effects: {},
pickingRadius: {},
onBeforeRender: {},
onAfterRender: {},
onClick: {},
onHover: {},
onDragStart: {},
onDrag: {},
onDragEnd: {},
onError: {},
debug: {},
drawPickingColors: {},
getCursor: {},
getTooltip: {}
};
/* eslint-disable callback-return */
export default function createDeckProps(Accessor) {
const DeckProps = Accessor.createSubclass({
properties,
constructor() {
this._callbacks = {};
this.watch(Object.keys(properties), (newValue, oldValue, propName) => {
this.emit('change', {[propName]: newValue});
});
},
on(eventName, cb) {
this._callbacks[eventName] = this._callbacks[eventName] || [];
this._callbacks[eventName].push(cb);
},
emit(eventName, details) {
const callbacks = this._callbacks[eventName];
if (callbacks) {
for (const cb of callbacks) {
cb(details);
}
}
},
toJSON() {
const result = {};
for (const key of this.keys()) {
if (this[key] !== undefined) {
result[key] = this[key];
}
}
return result;
}
});
return DeckProps;
}