diff --git a/application/controllers/Station.php b/application/controllers/Station.php index f7afddada..78f138d32 100644 --- a/application/controllers/Station.php +++ b/application/controllers/Station.php @@ -171,4 +171,13 @@ class Station extends CI_Controller redirect('stationsetup'); } + public function stationProfileCoords($id) { + $id = $this->security->xss_clean($id); + $this->load->model('stations'); + if ($this->stations->check_station_is_accessible($id)) { + $coords = $this->stations->lookupProfileCoords($id); + print json_encode($coords); + } + } + } diff --git a/application/models/Stations.php b/application/models/Stations.php index c59704c3a..d41d80254 100644 --- a/application/models/Stations.php +++ b/application/models/Stations.php @@ -601,6 +601,21 @@ class Stations extends CI_Model { if (($station_lat!=0)&&($station_lng!=0)) { $_jsonresult = array('lat'=>$station_lat,'lng'=>$station_lng,'html'=>$station_active->station_gridsquare,'label'=>$station_active->station_profile_name,'icon'=>'stationIcon'); } return (count($_jsonresult)>0)?(array('station'=>$_jsonresult)):array(); } + + public function lookupProfileCoords($stationid) { + $sql = "SELECT station_gridsquare FROM station_profile WHERE station_id = ?;"; + $query = $this->db->query($sql, $stationid); + if ($query->num_rows() == 1) { + $row = $query->row(); + if ($row->station_gridsquare != '') { + if (!$this->load->is_loaded('Qra')) { + $this->load->library('Qra'); + } + return $this->qra->qra2latlong($row->station_gridsquare); + } + } + return false; + } } ?> diff --git a/application/views/qso/index.php b/application/views/qso/index.php index 83d74988c..993934697 100644 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -305,7 +305,7 @@
- result() as $stationrow) { diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index becb9e7ec..7d5559efd 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -506,6 +506,7 @@ $('#btn_fullreset').on("click", function () { function reset_to_default() { reset_fields(); + panMap(activeStationId); $("#stationProfile").val(activeStationId); $("#selectPropagation").val(""); $("#frequency_rx").val(""); @@ -1254,6 +1255,22 @@ function testTimeOffConsistency() { return true; } +function panMap(stationProfileIndex) { + $.ajax({ + url: base_url + 'index.php/station/stationProfileCoords/'+stationProfileIndex, + type: 'get', + success: function(data) { + result = JSON.parse(data); + if (typeof result[0] !== "undefined" && typeof result[1] !== "undefined") { + mymap.panTo([result[0], result[1]]); + pos = result; + } + }, + error: function() { + }, + }); +} + $(document).ready(function () { qrg_inputtype(); clearTimeout();