mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Geomap: use a common configuration builder to find location fields (#36768)
This commit is contained in:
@@ -6,6 +6,37 @@ import { GrafanaTheme2 } from '../themes';
|
||||
import { PanelOptionsEditorBuilder } from '../utils';
|
||||
import { ReactNode } from 'react';
|
||||
|
||||
/**
|
||||
* @alpha
|
||||
*/
|
||||
export enum FrameGeometrySourceMode {
|
||||
Auto = 'auto', // Will scan fields and find best match
|
||||
Geohash = 'geohash',
|
||||
Coords = 'coords', // lon field, lat field
|
||||
Lookup = 'lookup', // keys > location
|
||||
// H3 = 'h3',
|
||||
// WKT = 'wkt,
|
||||
// geojson? geometry text
|
||||
}
|
||||
|
||||
/**
|
||||
* @alpha
|
||||
*/
|
||||
export interface FrameGeometrySource {
|
||||
mode: FrameGeometrySourceMode;
|
||||
|
||||
// Field mappings
|
||||
geohash?: string;
|
||||
latitude?: string;
|
||||
longitude?: string;
|
||||
h3?: string;
|
||||
wkt?: string;
|
||||
lookup?: string;
|
||||
|
||||
// Path to a mappings file
|
||||
lookupSrc: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* This gets saved in panel json
|
||||
*
|
||||
@@ -16,17 +47,20 @@ import { ReactNode } from 'react';
|
||||
*
|
||||
* @alpha
|
||||
*/
|
||||
export interface MapLayerConfig<TCustom = any> {
|
||||
export interface MapLayerOptions<TConfig = any> {
|
||||
type: string;
|
||||
name?: string; // configured display name
|
||||
|
||||
// Custom options depending on the type
|
||||
config?: TConfig;
|
||||
|
||||
// Common method to define geometry fields
|
||||
location?: FrameGeometrySource;
|
||||
|
||||
// Common properties:
|
||||
// https://openlayers.org/en/latest/apidoc/module-ol_layer_Base-BaseLayer.html
|
||||
// Layer opacity (0-1)
|
||||
opacity?: number;
|
||||
|
||||
// Custom options depending on the type
|
||||
config?: TCustom;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,22 +77,27 @@ export interface MapLayerHandler {
|
||||
*
|
||||
* @alpha
|
||||
*/
|
||||
export interface MapLayerRegistryItem<TConfig = MapLayerConfig> extends RegistryItemWithOptions {
|
||||
export interface MapLayerRegistryItem<TConfig = MapLayerOptions> extends RegistryItemWithOptions {
|
||||
/**
|
||||
* This layer can be used as a background
|
||||
*/
|
||||
isBaseMap?: boolean;
|
||||
|
||||
/**
|
||||
* Show location controls
|
||||
*/
|
||||
showLocation?: boolean;
|
||||
|
||||
/**
|
||||
* Show transparency controls in UI (for non-basemaps)
|
||||
*/
|
||||
showTransparency?: boolean;
|
||||
showOpacity?: boolean;
|
||||
|
||||
/**
|
||||
* Function that configures transformation and returns a transformer
|
||||
* @param options
|
||||
*/
|
||||
create: (map: Map, options: MapLayerConfig<TConfig>, theme: GrafanaTheme2) => MapLayerHandler;
|
||||
create: (map: Map, options: MapLayerOptions<TConfig>, theme: GrafanaTheme2) => MapLayerHandler;
|
||||
|
||||
/**
|
||||
* Show custom elements in the panel edit UI
|
||||
|
||||
Reference in New Issue
Block a user