Parameters now url get params

This commit is contained in:
Andreas Kristiansen
2024-04-08 18:35:10 +02:00
parent 2603ad08da
commit e2ad5eee16
3 changed files with 50 additions and 12 deletions

View File

@@ -25,6 +25,9 @@ class Visitor extends CI_Controller {
}
elseif($method == "exportmap") {
$this->exportmap();
}
elseif($method == "mapqsos") {
$this->mapqsos();
}
else {
$this->index($method);
@@ -414,8 +417,8 @@ class Visitor extends CI_Controller {
}
public function exportmap() {
$slug = $this->security->xss_clean($this->uri->segment(3));
$data['slug'] = $slug;
// $data['slug'] = $this->security->xss_clean($this->uri->segment(3));
// $data['qsocount'] = $this->security->xss_clean($this->uri->segment(4));
$data['page_title'] = "Export Map";
$this->load->view('visitor/exportmap/header', $data);
@@ -423,4 +426,35 @@ class Visitor extends CI_Controller {
$this->load->view('visitor/exportmap/footer');
}
public function mapqsos() {
$this->load->model('logbook_model');
$this->load->library('qra');
$slug = $this->security->xss_clean($this->input->get('slug'));
$qsocount = $this->security->xss_clean($this->input->get('qsocount')) == '' ? '100' : $this->security->xss_clean($this->input->get('qsocount'));
$this->load->model('logbooks_model');
$logbook_id = $this->logbooks_model->public_slug_exists_logbook_id($slug);
if($logbook_id != false)
{
// Get associated station locations for mysql queries
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($logbook_id);
if (!$logbooks_locations_array) {
show_404('Empty Logbook');
}
} else {
log_message('error', $slug.' has no associated station locations');
show_404('Unknown Public Page.');
}
$qsos = $this->logbook_model->get_qsos($qsocount, null, $logbooks_locations_array);
// [PLOT] ADD plot //
$plot_array = $this->logbook_model->get_plot_array_for_map($qsos->result());
header('Content-Type: application/json; charset=utf-8');
echo json_encode($plot_array);
}
}

View File

@@ -1,6 +1,3 @@
<script>
var slug = '<?php echo $slug; ?>';
</script>
<style>
#exportmap {
height: calc(100vh - 480px) !important;

View File

@@ -3,23 +3,28 @@ $(document).ready(function () {
});
function mapQsos(form) {
$('#mapButton').prop("disabled", true).addClass("running");
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const slug = urlParams.get('slug');
const qsocount = urlParams.get('qsocount');
const showgrid = urlParams.get('showgrid');
$.ajax({
url: base_url + 'index.php/visitor/map/'+slug,
type: 'post',
url: base_url + 'index.php/visitor/mapqsos/',
type: 'get',
data: {
qsocount: '100'
slug: slug,
qsocount: qsocount
},
success: function(data) {
loadMap(data);
loadMap(data, showgrid);
},
error: function() {
},
});
};
function loadMap(data) {
function loadMap(data, showgrid) {
var osmUrl='https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
var osmAttrib='Map data © <a href="https://openstreetmap.org">OpenStreetMap</a> contributors';
// If map is already initialized
@@ -70,7 +75,9 @@ function loadMap(data) {
var marker = L.marker([this.lat, this.lng], {icon: redIcon}, {closeOnClick: false, autoClose: false}).addTo(map);
});
maidenhead = L.maidenheadqrb().addTo(map);
if (showgrid === "true") {
maidenhead = L.maidenheadqrb().addTo(map);
}
map.addLayer(osm);