mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 23:33:29 +08:00
Geomap: Base layer server configuration (#37041)
This commit is contained in:
@ -1011,3 +1011,10 @@ default_timezone = browser
|
|||||||
[expressions]
|
[expressions]
|
||||||
# Enable or disable the expressions functionality.
|
# Enable or disable the expressions functionality.
|
||||||
enabled = true
|
enabled = true
|
||||||
|
|
||||||
|
[geomap]
|
||||||
|
# Set the default base layer in GeoMaps plugin
|
||||||
|
default_baselayer =
|
||||||
|
|
||||||
|
# Enable or disable loading other base map layers
|
||||||
|
disable_custom_baselayers = false
|
||||||
|
@ -991,3 +991,10 @@
|
|||||||
[expressions]
|
[expressions]
|
||||||
# Enable or disable the expressions functionality.
|
# Enable or disable the expressions functionality.
|
||||||
;enabled = true
|
;enabled = true
|
||||||
|
|
||||||
|
[geomap]
|
||||||
|
# Set the default base layer in GeoMaps plugin
|
||||||
|
;default_baselayer =
|
||||||
|
|
||||||
|
# Enable or disable loading other base map layers
|
||||||
|
;disable_custom_baselayers = false
|
||||||
|
@ -1672,3 +1672,26 @@ Used as the default time zone for user preferences. Can be either `browser` for
|
|||||||
### enabled
|
### enabled
|
||||||
|
|
||||||
Set this to `false` to disable expressions and hide them in the Grafana UI. Default is `true`.
|
Set this to `false` to disable expressions and hide them in the Grafana UI. Default is `true`.
|
||||||
|
|
||||||
|
## [geomap]
|
||||||
|
|
||||||
|
This section controls the defaults settings for Geomap Plugin.
|
||||||
|
|
||||||
|
### default_baselayer
|
||||||
|
|
||||||
|
The json config used to define the default base map. Four base map options to choose from are `carto`, `esriXYZTiles`, `xyzTiles`, `standard`.
|
||||||
|
For example, to set cartoDB light as the default base layer:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
geomap_default_baselayer = `{
|
||||||
|
"type": "carto",
|
||||||
|
"config": {
|
||||||
|
"theme": "light",
|
||||||
|
"showLabels": true
|
||||||
|
}
|
||||||
|
}`
|
||||||
|
```
|
||||||
|
|
||||||
|
### disable_custom_baselayers
|
||||||
|
|
||||||
|
Set this to `true` to disable loading other custom base maps and hide them in the Grafana UI. Default is `false`.
|
@ -3,6 +3,7 @@ import { PanelPluginMeta } from './panel';
|
|||||||
import { GrafanaTheme } from './theme';
|
import { GrafanaTheme } from './theme';
|
||||||
import { SystemDateFormatSettings } from '../datetime';
|
import { SystemDateFormatSettings } from '../datetime';
|
||||||
import { GrafanaTheme2 } from '../themes';
|
import { GrafanaTheme2 } from '../themes';
|
||||||
|
import { MapLayerOptions } from '../geo/layer';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describes the build information that will be available via the Grafana configuration.
|
* Describes the build information that will be available via the Grafana configuration.
|
||||||
@ -125,4 +126,6 @@ export interface GrafanaConfig {
|
|||||||
dateFormats?: SystemDateFormatSettings;
|
dateFormats?: SystemDateFormatSettings;
|
||||||
sentry: SentryConfig;
|
sentry: SentryConfig;
|
||||||
customTheme?: any;
|
customTheme?: any;
|
||||||
|
geomapDefaultBaseLayer?: MapLayerOptions;
|
||||||
|
geomapDisableCustomBaseLayer?: boolean;
|
||||||
}
|
}
|
||||||
|
@ -259,6 +259,8 @@ func (hs *HTTPServer) getFrontendSettingsMap(c *models.ReqContext) (map[string]i
|
|||||||
"caching": map[string]bool{
|
"caching": map[string]bool{
|
||||||
"enabled": hs.Cfg.SectionWithEnvOverrides("caching").Key("enabled").MustBool(true),
|
"enabled": hs.Cfg.SectionWithEnvOverrides("caching").Key("enabled").MustBool(true),
|
||||||
},
|
},
|
||||||
|
"geomapDefaultBaseLayer": hs.Cfg.DefaultBaseLayer,
|
||||||
|
"geomapDisableCustomBaseLayer": hs.Cfg.DisableCustomBaseLayers,
|
||||||
}
|
}
|
||||||
|
|
||||||
return jsonObj, nil
|
return jsonObj, nil
|
||||||
|
@ -5,6 +5,7 @@ package setting
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -400,6 +401,10 @@ type Cfg struct {
|
|||||||
|
|
||||||
// Grafana.com URL
|
// Grafana.com URL
|
||||||
GrafanaComURL string
|
GrafanaComURL string
|
||||||
|
|
||||||
|
// Geomap plugin tile server
|
||||||
|
DefaultBaseLayer map[string]interface{}
|
||||||
|
DisableCustomBaseLayers bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsLiveConfigEnabled returns true if live should be able to save configs to SQL tables
|
// IsLiveConfigEnabled returns true if live should be able to save configs to SQL tables
|
||||||
@ -966,6 +971,18 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
|
|||||||
ConnStr: connStr,
|
ConnStr: connStr,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
geomapSection := iniFile.Section("geomap")
|
||||||
|
basemapJSON := valueAsString(geomapSection, "default_baselayer", "")
|
||||||
|
cfg.DefaultBaseLayer = make(map[string]interface{})
|
||||||
|
if basemapJSON != "" {
|
||||||
|
err = json.Unmarshal([]byte(basemapJSON), &cfg.DefaultBaseLayer)
|
||||||
|
if err != nil {
|
||||||
|
cfg.Logger.Error(fmt.Sprintf("Error parsing JSON string: %s", err))
|
||||||
|
cfg.DefaultBaseLayer = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cfg.DisableCustomBaseLayers = geomapSection.Key("disable_custom_baselayers").MustBool(false)
|
||||||
|
|
||||||
cfg.readDateFormats()
|
cfg.readDateFormats()
|
||||||
cfg.readSentryConfig()
|
cfg.readSentryConfig()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user