Skip to content

gi-nx


gi-nx / createLayer

ts
function createLayer(layerPost: 
  | {
  boundary?: {
     geojson: string;
     wkid: number;
  };
  credentials?: {
     password?: string;
     token?: string;
     username?: string;
  };
  data_date?: string;
  default_group: string;
  description: string;
  layer_type: GiraffeLayerType;
  meta: Record<any, any>;
  name: string;
  org_id: string;
  protected?: boolean;
  public?: boolean;
  public_url: boolean;
  style:   | MapboxStyleLayer
     | MapboxStyleLayer[];
  tags?: string[];
  vector_source: null;
  vector_style: null;
}
  | {
  boundary?: {
     geojson: string;
     wkid: number;
  };
  credentials?: {
     password?: string;
     token?: string;
     username?: string;
  };
  data_date?: string;
  default_group: string;
  description: string;
  layer_type: VectorUpload | MapboxTiles;
  meta: Record<any, any>;
  name: string;
  org_id: string;
  protected?: boolean;
  public?: boolean;
  public_url: boolean;
  style: never;
  tags?: string[];
  vector_source:   | VectorSourceSpecification
     | RasterSourceSpecification
     | RasterDEMSourceSpecification
     | RasterArraySourceSpecification
     | GeoJSONSourceSpecification
     | VideoSourceSpecification
     | ImageSourceSpecification
     | ModelSourceSpecification
     | Gi3DSourceData;
  vector_style: {
     aggregateBy?: string;
     columnDef?: Record<string, LensTypedProperty>;
     columnKeys?: string[];
     filter?: AdvancedFeatureFilter;
     filterMode?: FilterMode;
     promoteId?: string;
     sortBy?: SortBy[];
     sortDescending?: boolean;
     sourceLayer?: string;
   } & {
     baseHeightKey?: string;
     circleRadius?: number;
     cluster?: boolean;
     clusterColor?: string;
     displayKeys?: string[];
     fillOpacity?: number;
     heightKey?: string;
     heightScale?: number;
     iconColor?: ColorPaletteOrFixed;
     iconHaloColor?: ColorPaletteOrFixed;
     iconImage?: string;
     iconSize?: number;
     lineColor?: ColorPaletteOrFixed;
     lineDimension?: "meters" | "pixels";
     lineWidth?: number;
     mainColor?: ColorPaletteOrFixed;
     mainLayer?: "fill" | "fill-extrusion" | "circle" | "icon" | "model" | "giraffe-baked";
     overrideCircle?: Pick<CircleLayerSpecification, "paint">;
     overrideFill?: Pick<FillLayerSpecification, "paint">;
     overrideFillExtrusion?: Pick<FillExtrusionLayerSpecification, "paint" | "layout">;
     overrideIcon?: Pick<SymbolLayerSpecification, "paint" | "layout">;
     overrideLabel?: Pick<SymbolLayerSpecification, "paint" | "layout">;
     overrideLine?: Pick<LineLayerSpecification, "paint" | "layout">;
     overrideModel?: Pick<ModelLayerSpecification, "paint" | "layout">;
     primaryLabelMaxChars?: number;
     props?: PropToProp[];
     showLabels?: boolean;
     showLines?: boolean;
     showPalette?: LensPaletteKey;
     showTable?: boolean;
     showValuesOnly?: boolean;
     tableColumnWidths?: Record<string, number>;
     textColor?: ColorPaletteOrFixed;
     textHaloColor?: ColorPaletteOrFixed;
  };
}): Promise<Layer>;

Create a layer with full configuration options.

Parameters

ParameterType
layerPost| { boundary?: { geojson: string; wkid: number; }; credentials?: { password?: string; token?: string; username?: string; }; data_date?: string; default_group: string; description: string; layer_type: GiraffeLayerType; meta: Record<any, any>; name: string; org_id: string; protected?: boolean; public?: boolean; public_url: boolean; style: | MapboxStyleLayer | MapboxStyleLayer[]; tags?: string[]; vector_source: null; vector_style: null; } | { boundary?: { geojson: string; wkid: number; }; credentials?: { password?: string; token?: string; username?: string; }; data_date?: string; default_group: string; description: string; layer_type: VectorUpload | MapboxTiles; meta: Record<any, any>; name: string; org_id: string; protected?: boolean; public?: boolean; public_url: boolean; style: never; tags?: string[]; vector_source: | VectorSourceSpecification | RasterSourceSpecification | RasterDEMSourceSpecification | RasterArraySourceSpecification | GeoJSONSourceSpecification | VideoSourceSpecification | ImageSourceSpecification | ModelSourceSpecification | Gi3DSourceData; vector_style: { aggregateBy?: string; columnDef?: Record<string, LensTypedProperty>; columnKeys?: string[]; filter?: AdvancedFeatureFilter; filterMode?: FilterMode; promoteId?: string; sortBy?: SortBy[]; sortDescending?: boolean; sourceLayer?: string; } & { baseHeightKey?: string; circleRadius?: number; cluster?: boolean; clusterColor?: string; displayKeys?: string[]; fillOpacity?: number; heightKey?: string; heightScale?: number; iconColor?: ColorPaletteOrFixed; iconHaloColor?: ColorPaletteOrFixed; iconImage?: string; iconSize?: number; lineColor?: ColorPaletteOrFixed; lineDimension?: "meters" | "pixels"; lineWidth?: number; mainColor?: ColorPaletteOrFixed; mainLayer?: "fill" | "fill-extrusion" | "circle" | "icon" | "model" | "giraffe-baked"; overrideCircle?: Pick<CircleLayerSpecification, "paint">; overrideFill?: Pick<FillLayerSpecification, "paint">; overrideFillExtrusion?: Pick<FillExtrusionLayerSpecification, "paint" | "layout">; overrideIcon?: Pick<SymbolLayerSpecification, "paint" | "layout">; overrideLabel?: Pick<SymbolLayerSpecification, "paint" | "layout">; overrideLine?: Pick<LineLayerSpecification, "paint" | "layout">; overrideModel?: Pick<ModelLayerSpecification, "paint" | "layout">; primaryLabelMaxChars?: number; props?: PropToProp[]; showLabels?: boolean; showLines?: boolean; showPalette?: LensPaletteKey; showTable?: boolean; showValuesOnly?: boolean; tableColumnWidths?: Record<string, number>; textColor?: ColorPaletteOrFixed; textHaloColor?: ColorPaletteOrFixed; }; }

Returns

Promise<Layer>

Needs Permission

Example

typescript
rpc.invoke("createLayer", [{
  name: "Custom Layer",
  source: { type: "vector", url: "https://tileserver.com/{z}/{x}/{y}.pbf" },
  "source-layer": "layer",
  style: layerStyle
}]).then(l => rpc.invoke('addLayerToProject',[l.id]));