From cbda218a145766b21b584bb9d11126e1a3962c37 Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Tue, 13 Jul 2021 13:45:12 -0700 Subject: [PATCH] Geomap: rename "circles" layer to "markers" layer (#36727) --- .../plugins/panel/geomap/layers/data/index.ts | 4 +- .../{circlesOverlay.ts => markersLayer.ts} | 102 +++++++++--------- 2 files changed, 54 insertions(+), 52 deletions(-) rename public/app/plugins/panel/geomap/layers/data/{circlesOverlay.ts => markersLayer.ts} (92%) diff --git a/public/app/plugins/panel/geomap/layers/data/index.ts b/public/app/plugins/panel/geomap/layers/data/index.ts index 9f0fd8defee..f6a3ce13a95 100644 --- a/public/app/plugins/panel/geomap/layers/data/index.ts +++ b/public/app/plugins/panel/geomap/layers/data/index.ts @@ -1,4 +1,4 @@ -import { circlesLayer } from './circlesOverlay'; +import { markersLayer } from './markersLayer'; import { geojsonMapper } from './geojsonMapper'; import { lastPointTracker } from './lastPointTracker'; @@ -6,7 +6,7 @@ import { lastPointTracker } from './lastPointTracker'; * Registry for layer handlers */ export const dataLayers = [ - circlesLayer, + markersLayer, lastPointTracker, geojsonMapper, // dummy for now ]; diff --git a/public/app/plugins/panel/geomap/layers/data/circlesOverlay.ts b/public/app/plugins/panel/geomap/layers/data/markersLayer.ts similarity index 92% rename from public/app/plugins/panel/geomap/layers/data/circlesOverlay.ts rename to public/app/plugins/panel/geomap/layers/data/markersLayer.ts index 60165f386c1..12717f6310a 100644 --- a/public/app/plugins/panel/geomap/layers/data/circlesOverlay.ts +++ b/public/app/plugins/panel/geomap/layers/data/markersLayer.ts @@ -9,7 +9,7 @@ import * as style from 'ol/style'; import tinycolor from 'tinycolor2'; // Configuration options for Circle overlays -export interface CircleConfig { +export interface MarkersConfig { queryFormat: QueryFormat, fieldMapping: FieldMappingOptions, minSize: number, @@ -17,7 +17,7 @@ export interface CircleConfig { opacity: number, } -const defaultOptions: CircleConfig = { +const defaultOptions: MarkersConfig = { queryFormat: { locationType: 'coordinates', }, @@ -32,20 +32,22 @@ const defaultOptions: CircleConfig = { opacity: 0.4, }; +export const MARKERS_LAYER_ID = "markers"; + /** * Map layer configuration for circle overlay */ -export const circlesLayer: MapLayerRegistryItem = { - id: 'circles', - name: 'Circles', - description: 'creates circle overlays for data values', +export const markersLayer: MapLayerRegistryItem = { + id: MARKERS_LAYER_ID, + name: 'Markers', + description: 'use markers to render each data point', isBaseMap: false, /** * Function that configures transformation and returns a transformer * @param options */ - create: (map: Map, options: MapLayerConfig, theme: GrafanaTheme2): MapLayerHandler => { + create: (map: Map, options: MapLayerConfig, theme: GrafanaTheme2): MapLayerHandler => { const config = { ...defaultOptions, ...options.config }; const vectorLayer = new layer.Vector({}); @@ -114,6 +116,49 @@ export const circlesLayer: MapLayerRegistryItem = { // Circle overlay options registerOptionsUI: (builder) => { builder + .addSelect({ + path: 'queryFormat.locationType', + name: 'Location source', + defaultValue: defaultOptions.queryFormat.locationType, + settings: { + options: [ + { + value: 'coordinates', + label: 'Latitude/Longitude fields', + }, + { + value: 'geohash', + label: 'Geohash field', + }, + ], + }, + }) + .addTextInput({ + path: 'fieldMapping.latitudeField', + name: 'Latitude Field', + defaultValue: defaultOptions.fieldMapping.latitudeField, + showIf: (config) => + config.queryFormat.locationType === 'coordinates', + }) + .addTextInput({ + path: 'fieldMapping.longitudeField', + name: 'Longitude Field', + defaultValue: defaultOptions.fieldMapping.longitudeField, + showIf: (config) => + config.queryFormat.locationType === 'coordinates', + }) + .addTextInput({ + path: 'fieldMapping.geohashField', + name: 'Geohash Field', + defaultValue: defaultOptions.fieldMapping.geohashField, + showIf: (config) => + config.queryFormat.locationType === 'geohash', + }) + .addTextInput({ + path: 'fieldMapping.metricField', + name: 'Metric Field', + defaultValue: defaultOptions.fieldMapping.metricField, + }) .addNumberInput({ path: 'minSize', description: 'configures the min circle size', @@ -136,49 +181,6 @@ export const circlesLayer: MapLayerRegistryItem = { max: 1, step: 0.1, }, - }) - .addSelect({ - path: 'queryFormat.locationType', - name: 'Query Format', - defaultValue: defaultOptions.queryFormat.locationType, - settings: { - options: [ - { - value: 'coordinates', - label: 'Coordinates', - }, - { - value: 'geohash', - label: 'Geohash', - }, - ], - }, - }) - .addTextInput({ - path: 'fieldMapping.metricField', - name: 'Metric Field', - defaultValue: defaultOptions.fieldMapping.metricField, - }) - .addTextInput({ - path: 'fieldMapping.latitudeField', - name: 'Latitude Field', - defaultValue: defaultOptions.fieldMapping.latitudeField, - showIf: (config) => - config.queryFormat.locationType === 'coordinates', - }) - .addTextInput({ - path: 'fieldMapping.longitudeField', - name: 'Longitude Field', - defaultValue: defaultOptions.fieldMapping.longitudeField, - showIf: (config) => - config.queryFormat.locationType === 'coordinates', - }) - .addTextInput({ - path: 'fieldMapping.geohashField', - name: 'Geohash Field', - defaultValue: defaultOptions.fieldMapping.geohashField, - showIf: (config) => - config.queryFormat.locationType === 'geohash', }); }, // fill in the default values