diff --git a/application/controllers/Gridmap.php b/application/controllers/Gridmap.php index 152e0f460..5082220f6 100644 --- a/application/controllers/Gridmap.php +++ b/application/controllers/Gridmap.php @@ -72,6 +72,8 @@ class Gridmap extends CI_Controller { $this->load->model('gridmap_model'); + $data['country_coords'] = $this->gridmap_model->get_coordinates_for_dxcc($dxcc); + $data['grids'] = $this->gridmap_model->get_grids_for_country($dxcc); $data['grid_count'] = count($data['grids']); diff --git a/application/models/Gridmap_model.php b/application/models/Gridmap_model.php index b6f2e5872..014b86d61 100644 --- a/application/models/Gridmap_model.php +++ b/application/models/Gridmap_model.php @@ -390,4 +390,24 @@ class Gridmap_model extends CI_Model { return $gridarray; } + + function get_coordinates_for_dxcc($dxcc) { + // Get country coordinates if a specific country is selected + $country_coords = null; + if ($dxcc && $dxcc != 'All') { + // Query dxcc_entities table for country info + $sql = "SELECT adif, lat, `long`, name FROM dxcc_entities WHERE adif = ?"; + $query = $this->db->query($sql, array($dxcc)); + + if ($query && $query->num_rows() > 0) { + $country_info = $query->row(); + $country_coords = [ + 'lat' => (float)$country_info->lat, + 'long' => (float)$country_info->long, + 'name' => $country_info->name + ]; + } + } + return $country_coords; + } } diff --git a/application/views/gridmap/index.php b/application/views/gridmap/index.php index afdcf807b..2728de6b8 100644 --- a/application/views/gridmap/index.php +++ b/application/views/gridmap/index.php @@ -145,7 +145,7 @@ result()) > 0) { ?> - +