diff --git a/components/lazmapviewer/example/main.pas b/components/lazmapviewer/example/main.pas index 81f4ab4a5..e71ac2d11 100644 --- a/components/lazmapviewer/example/main.pas +++ b/components/lazmapviewer/example/main.pas @@ -421,7 +421,11 @@ begin try HERE_AppID := ini.ReadString('HERE', 'APP_ID', ''); HERE_AppCode := ini.ReadString('HERE', 'APP_CODE', ''); - if (HERE_AppID <> '') and (HERE_AppCode <> '') then begin + OpenWeatherMap_ApiKey := ini.ReadString('OpenWeatherMap', 'API_Key', ''); + + if ((HERE_AppID <> '') and (HERE_AppCode <> '')) or + (OpenWeatherMap_ApiKey <> '') then + begin MapView.Engine.ClearMapProviders; MapView.Engine.RegisterProviders; MapView.GetMapProviders(CbProviders.Items); @@ -585,6 +589,9 @@ begin if HERE_AppCode <> '' then ini.WriteString('HERE', 'APP_CODE', HERE_AppCode); + if OpenWeatherMap_ApiKey <> '' then + ini.WriteString('OpenWeatherMap', 'API_Key', OpenWeatherMap_ApiKey); + ini.EraseSection('Locations'); for i := 0 to CbLocations.Items.Count-1 do ini.WriteString('Locations', 'Item'+IntToStr(i), CbLocations.Items[i]); diff --git a/components/lazmapviewer/source/mvengine.pas b/components/lazmapviewer/source/mvengine.pas index d095d9cf7..c53c48f2b 100644 --- a/components/lazmapviewer/source/mvengine.pas +++ b/components/lazmapviewer/source/mvengine.pas @@ -177,6 +177,7 @@ procedure SplitGps(AValue: Double; out ADegs, AMins, ASecs: Double); var HERE_AppID: String = ''; HERE_AppCode: String = ''; + OpenWeatherMap_ApiKey: String = ''; implementation @@ -921,6 +922,28 @@ begin 1, 19, 4, @GetYahooSvr); end; + if (OpenWeatherMap_ApiKey <> '') then begin + // Registration required to access OpenWeatherMaps + // https://home.openweathermap.org/users/sign_up + // Store the API key found on the website in the ini file of the demo under + // key [OpenWeatherMap] and API_Key and restart the demo + AddMapProvider('OpenWeatherMap Clouds', + 'https://tile.openweathermap.org/map/clouds_new/%z%/%x%/%y%.png?appid=' + OpenWeatherMap_ApiKey, + 1, 19, 1, nil); + AddMapProvider('OpenWeatherMap Precipitation', + 'https://tile.openweathermap.org/map/precipitation_new/%z%/%x%/%y%.png?appid=' + OpenWeatherMap_ApiKey, + 1, 19, 1, nil); + AddMapProvider('OpenWeatherMap Pressure', + 'https://tile.openweathermap.org/map/pressure_new/%z%/%x%/%y%.png?appid=' + OpenWeatherMap_ApiKey, + 1, 19, 1, nil); + AddMapProvider('OpenWeatherMap Temperature', + 'https://tile.openweathermap.org/map/temp_new/%z%/%x%/%y%.png?appid=' + OpenWeatherMap_ApiKey, + 1, 19, 1, nil); + AddMapProvider('OpenWeatherMap Wind', + 'https://tile.openweathermap.org/map/wind_new/%z%/%x%/%y%.png?appid=' + OpenWeatherMap_ApiKey, + 1, 19, 1, nil); + end; + { The Ovi Maps (former Nokia maps) are no longer available. AddMapProvider('Ovi Normal',