The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/plugins/panel/geomap/layers/registry.ts

42 lines
1.4 KiB

import { MapLayerRegistryItem, Registry, MapLayerOptions, GrafanaTheme2 } from '@grafana/data';
import Map from 'ol/Map';
import { carto } from './basemaps/carto';
import { config } from 'app/core/config';
import { basemapLayers } from './basemaps';
import { dataLayers } from './data';
export const DEFAULT_BASEMAP_CONFIG: MapLayerOptions = {
type: 'default',
name: '', // will get filled in with a non-empty name
config: {},
};
// Default base layer depending on the server setting
export const defaultBaseLayer: MapLayerRegistryItem = {
id: DEFAULT_BASEMAP_CONFIG.type,
name: 'Default base layer',
isBaseMap: true,
create: (map: Map, options: MapLayerOptions, theme: GrafanaTheme2) => {
const serverLayerType = config?.geomapDefaultBaseLayerConfig?.type;
if (serverLayerType) {
const layer = geomapLayerRegistry.getIfExists(serverLayerType);
if (!layer) {
throw new Error('Invalid basemap configuraiton on server');
}
return layer.create(map, config.geomapDefaultBaseLayerConfig!, theme);
}
// For now use carto as our default basemap
return carto.create(map, options, theme);
},
};
/**
* Registry for layer handlers
*/
export const geomapLayerRegistry = new Registry<MapLayerRegistryItem<any>>(() => [
defaultBaseLayer,
...basemapLayers, // simple basemaps
...dataLayers, // Layers with update functions
]);