support google map

This commit is contained in:
MaysWind
2023-06-17 23:14:09 +08:00
parent 38baf77c30
commit a5dbf5d4b7
10 changed files with 170 additions and 14 deletions
@@ -23,6 +23,10 @@ func ServerSettingsCookie(config *settings.Config) core.MiddlewareHandlerFunc {
settingsArr = append(settingsArr, buildBooleanSetting("mp", config.EnableMapDataFetchProxy))
}
if config.GoogleMapAPIKey != "" {
settingsArr = append(settingsArr, buildStringSetting("gmak", config.GoogleMapAPIKey))
}
if config.BaiduMapAK != "" {
settingsArr = append(settingsArr, buildStringSetting("bmak", config.BaiduMapAK))
}
+5
View File
@@ -65,6 +65,7 @@ const (
// Map provider types
const (
OpenStreetMapProvider string = "openstreetmap"
GoogleMapProvider string = "googlemap"
BaiduMapProvider string = "baidumap"
)
@@ -177,6 +178,7 @@ type Config struct {
// Map
MapProvider string
GoogleMapAPIKey string
BaiduMapAK string
EnableMapDataFetchProxy bool
@@ -438,6 +440,8 @@ func loadMapConfiguration(config *Config, configFile *ini.File, sectionName stri
config.MapProvider = ""
} else if getConfigItemStringValue(configFile, sectionName, "map_provider") == OpenStreetMapProvider {
config.MapProvider = OpenStreetMapProvider
} else if getConfigItemStringValue(configFile, sectionName, "map_provider") == GoogleMapProvider {
config.MapProvider = GoogleMapProvider
} else if getConfigItemStringValue(configFile, sectionName, "map_provider") == BaiduMapProvider {
config.MapProvider = BaiduMapProvider
} else {
@@ -445,6 +449,7 @@ func loadMapConfiguration(config *Config, configFile *ini.File, sectionName stri
}
config.EnableMapDataFetchProxy = getConfigItemBoolValue(configFile, sectionName, "map_data_fetch_proxy", false)
config.GoogleMapAPIKey = getConfigItemStringValue(configFile, sectionName, "google_map_api_key")
config.BaiduMapAK = getConfigItemStringValue(configFile, sectionName, "baidu_map_ak")
return nil