Skip to content

Instantly share code, notes, and snippets.

@priithaamer
Last active May 15, 2018 19:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save priithaamer/04d6ced8da681c8ab961437ccc77a281 to your computer and use it in GitHub Desktop.
Save priithaamer/04d6ced8da681c8ab961437ccc77a281 to your computer and use it in GitHub Desktop.
Partial implementation of deck.gl TypeScript definitions
declare module 'deck.gl' {
import * as React from 'react';
type HandlerInfo<T> = (info: { layer: BaseLayer<T>, index: number, object: T, x: number, y: number }) => boolean;
interface BaseLayerOptions<T> {
id?: string;
data?: T[];
visible?: boolean;
opacity?: number;
pickable?: boolean;
onHover?: HandlerInfo<T>;
onClick?: HandlerInfo<T>;
}
interface IconDefinition {
x: number;
y: number;
width: number;
height: number;
anchorX?: number;
anchorY?: number;
mask?: boolean
}
interface IconMapping {
[key: string]: IconDefinition;
}
interface IconLayerOptions<T> extends BaseLayerOptions<T> {
iconAtlas: string;
iconMapping: IconMapping;
sizeScale?: number;
fp64?: boolean;
getPosition?: (data: T) => [number, number, number];
getIcon?: (data: T) => string;
getSize?: (data: T) => number;
getColor?: (data: T) => [number, number, number];
getAngle?: (data: T) => number;
}
export class AbstractLayer { }
export class BaseLayer<T> extends AbstractLayer {
constructor(props: BaseLayerOptions<T>);
}
export class IconLayer<T> extends BaseLayer<T> {
constructor(props: IconLayerOptions<T>);
}
interface DeckGLProperties {
id?: string;
width?: number;
height?: number;
latitude?: number;
longitude?: number;
zoom?: number;
bearing?: number;
pitch?: number;
layers: AbstractLayer[];
style?: React.CSSProperties;
pickingRadius?: number;
pixelRatio?: number;
}
export default class DeckGL extends React.Component<DeckGLProperties> { }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment