grafana/public/app/plugins/panel/geomap/view.ts
Drew Slobodnjak 6e85dfa25a
Geomap: Add dynamic initial view options (#54419)
* Geomap: Add dynamic initial view options

* Add control options for dynamic initial view

* Add handling for last only scope

* Remove stale todos

* Only reinitialize map view during data if fit

* Add options for data fit

In map init, remove dependency on layers input.

Add a boolean to map view config to handle all layers, with default
set to true. Also, add layer string to handle currently selected layer.

Change some verbage.

In map view editor, add controls for data extent options. Only display
layer selection when all layers is not selected.

Update layer extent function to handle all options permutations. When
all layers is selected, return all data for extent calculation. When
last only is selected, only return last data point in matching layer for
extent calculation. Otherwise, return all data points in matching layer
for extent calculation.

* Change padding tooltip and hide for last only

* Simplify getLayersExtent call

* Add enums for data scope options

* Update GeomapPanel for refactor merge

* Move view init functions back into geomap class

Re-apply data change handling and extent calculation handling.

* Update padding tooltip verbage

* Ensure geomap panel options layers are initialized

* Clean up GeomapPanel file (betterer)

* refactors / clean up

* more cleanup

Co-authored-by: nmarrs <nathanielmarrs@gmail.com>
2022-09-21 13:11:44 -07:00

102 lines
1.5 KiB
TypeScript

import { Registry, RegistryItem } from '@grafana/data';
interface MapCenterItems extends RegistryItem {
lat?: number;
lon?: number;
zoom?: number;
}
export enum MapCenterID {
Zero = 'zero',
Coordinates = 'coords',
Fit = 'fit',
}
export const centerPointRegistry = new Registry<MapCenterItems>(() => [
{
id: MapCenterID.Fit as string,
name: 'Fit to data',
zoom: 15, // max zoom
},
{
id: MapCenterID.Zero as string,
name: '(0°, 0°)',
lat: 0,
lon: 0,
},
{
id: MapCenterID.Coordinates as string,
name: 'Coordinates',
},
{
id: 'north-america',
name: 'North America',
lat: 40,
lon: -100,
zoom: 4,
},
{
id: 'south-america',
name: 'South America',
lat: -20,
lon: -60,
zoom: 3,
},
{
id: 'europe',
name: 'Europe',
lat: 46,
lon: 14,
zoom: 4,
},
{
id: 'africa',
name: 'Africa',
lat: 0,
lon: 30,
zoom: 3,
},
{
id: 'west-asia',
name: 'West Asia',
lat: 26,
lon: 53,
zoom: 4,
},
{
id: 's-asia',
name: 'South Asia',
lat: 19.5,
lon: 80,
zoom: 4,
},
{
id: 'se-asia',
name: 'South-East Asia',
lat: 10,
lon: 106,
zoom: 4,
},
{
id: 'e-asia',
name: 'East Asia',
lat: 33,
lon: 120,
zoom: 4,
},
{
id: 'australia',
name: 'Australia',
lat: -25,
lon: 135,
zoom: 4,
},
{
id: 'oceania',
name: 'Oceania',
lat: -10,
lon: -140,
zoom: 3,
},
]);