diff --git a/src/app/Http/Controllers/SwitcherController.php b/src/app/Http/Controllers/SwitcherController.php index a97f63a15..da9f996e9 100644 --- a/src/app/Http/Controllers/SwitcherController.php +++ b/src/app/Http/Controllers/SwitcherController.php @@ -378,6 +378,9 @@ private function getServerInfo($request): BaseJsonResponse 'versionInt' => strval((intval($versionArray[0]) * 1000000) + (intval($versionArray[1]) * 1000) + intval($versionArray[2])), 'langs' => collect(scandir(base_path('lang')))->reject(fn ($dir) => $dir == '.' || $dir == '..')->sort()->join(','), 'nativeLang' => config('app.locale'), + 'centerLongitude' => strval(legacy_config('search_spec_map_center_longitude')), + 'centerLatitude' => strval(legacy_config('search_spec_map_center_latitude')), + 'centerZoom' => strval(legacy_config('search_spec_map_center_zoom')), 'defaultDuration' => legacy_config('default_duration_time'), 'regionBias' => legacy_config('region_bias'), 'charSet' => 'UTF-8', diff --git a/src/app/LegacyConfig.php b/src/app/LegacyConfig.php index 714a0b941..0293775f8 100644 --- a/src/app/LegacyConfig.php +++ b/src/app/LegacyConfig.php @@ -101,7 +101,9 @@ private static function loadConfig() $config['meeting_states_and_provinces'] = $meeting_states_and_provinces ?? []; $config['meeting_counties_and_sub_provinces'] = $meeting_counties_and_sub_provinces ?? []; $config['meeting_time_zones_enabled'] = isset($meeting_time_zones_enabled) && $meeting_time_zones_enabled; - + $config['search_spec_map_center_longitude'] = isset($search_spec_map_center) && is_array($search_spec_map_center) && isset($search_spec_map_center['longitude']) ? $search_spec_map_center['longitude'] : -118.563659; + $config['search_spec_map_center_latitude'] = isset($search_spec_map_center) && is_array($search_spec_map_center) && isset($search_spec_map_center['latitude']) ? $search_spec_map_center['latitude'] : 34.235918; + $config['search_spec_map_center_zoom'] = isset($search_spec_map_center) && is_array($search_spec_map_center) && isset($search_spec_map_center['zoom']) ? $search_spec_map_center['zoom'] : 6; self::$config = $config; self::$configLoaded = true; diff --git a/src/tests/Feature/GetServerInfoTest.php b/src/tests/Feature/GetServerInfoTest.php index 7ed997199..6efbab40b 100644 --- a/src/tests/Feature/GetServerInfoTest.php +++ b/src/tests/Feature/GetServerInfoTest.php @@ -241,4 +241,67 @@ public function testMeetingTimeZonesEnabled() LegacyConfig::reset(); } } + + public function testCenterLongitude() + { + LegacyConfig::remove('search_spec_map_center_longitude'); + try { + $this->get('/client_interface/json/?switcher=GetServerInfo') + ->assertStatus(200) + ->assertJsonFragment(['centerLongitude' => '']); + } finally { + LegacyConfig::reset(); + } + + LegacyConfig::set('search_spec_map_center_longitude', -79.793701171875); + try { + $this->get('/client_interface/json/?switcher=GetServerInfo') + ->assertStatus(200) + ->assertJsonFragment(['centerLongitude' => '-79.793701171875']); + } finally { + LegacyConfig::reset(); + } + } + + public function testCenterLatitude() + { + LegacyConfig::remove('search_spec_map_center_latitude'); + try { + $this->get('/client_interface/json/?switcher=GetServerInfo') + ->assertStatus(200) + ->assertJsonFragment(['centerLatitude' => '']); + } finally { + LegacyConfig::reset(); + } + + LegacyConfig::set('search_spec_map_center_latitude', 36.065752051707); + try { + $this->get('/client_interface/json/?switcher=GetServerInfo') + ->assertStatus(200) + ->assertJsonFragment(['centerLatitude' => '36.065752051707']); + } finally { + LegacyConfig::reset(); + } + } + + public function testCenterZoom() + { + LegacyConfig::remove('search_spec_map_center_zoom'); + try { + $this->get('/client_interface/json/?switcher=GetServerInfo') + ->assertStatus(200) + ->assertJsonFragment(['centerZoom' => '']); + } finally { + LegacyConfig::reset(); + } + + LegacyConfig::set('search_spec_map_center_zoom', 10); + try { + $this->get('/client_interface/json/?switcher=GetServerInfo') + ->assertStatus(200) + ->assertJsonFragment(['centerZoom' => '10']); + } finally { + LegacyConfig::reset(); + } + } }