[LBA] Added user options for map layers

This commit is contained in:
Andreas
2024-02-15 12:08:56 +01:00
parent 4879fbf560
commit b5106b2aff
4 changed files with 125 additions and 13 deletions

View File

@@ -36,6 +36,14 @@ class Logbookadvanced extends CI_Controller {
$data['options'] = $userOptions[0]->option_value;
}
$mapoptions['gridsquare_layer'] = $this->user_options_model->get_options('LogbookAdvancedMap',array('option_name'=>'gridsquare_layer','option_key'=>'boolean'))->row();
$mapoptions['path_lines'] = $this->user_options_model->get_options('LogbookAdvancedMap',array('option_name'=>'path_lines','option_key'=>'boolean'))->row();
$mapoptions['cqzones_layer'] = $this->user_options_model->get_options('LogbookAdvancedMap',array('option_name'=>'cqzones_layer','option_key'=>'boolean'))->row();
$mapoptions['ituzones_layer'] = $this->user_options_model->get_options('LogbookAdvancedMap',array('option_name'=>'ituzones_layer','option_key'=>'boolean'))->row();
$mapoptions['nightshadow_layer'] = $this->user_options_model->get_options('LogbookAdvancedMap',array('option_name'=>'nightshadow_layer','option_key'=>'boolean'))->row();
$data['mapoptions'] = $mapoptions;
$active_station_id = $this->stations->find_active();
$station_profile = $this->stations->profile($active_station_id);
@@ -440,6 +448,15 @@ class Logbookadvanced extends CI_Controller {
} else {
$data['options'] = null;
}
$mapoptions['gridsquare_layer'] = $this->user_options_model->get_options('LogbookAdvancedMap',array('option_name'=>'gridsquare_layer','option_key'=>'boolean'))->row();
$mapoptions['path_lines'] = $this->user_options_model->get_options('LogbookAdvancedMap',array('option_name'=>'path_lines','option_key'=>'boolean'))->row();
$mapoptions['cqzones_layer'] = $this->user_options_model->get_options('LogbookAdvancedMap',array('option_name'=>'cqzones_layer','option_key'=>'boolean'))->row();
$mapoptions['ituzones_layer'] = $this->user_options_model->get_options('LogbookAdvancedMap',array('option_name'=>'ituzones_layer','option_key'=>'boolean'))->row();
$mapoptions['nightshadow_layer'] = $this->user_options_model->get_options('LogbookAdvancedMap',array('option_name'=>'nightshadow_layer','option_key'=>'boolean'))->row();
$data['mapoptions'] = $mapoptions;
$this->load->view('logbookadvanced/useroptions', $data);
}
@@ -470,5 +487,12 @@ class Logbookadvanced extends CI_Controller {
$this->load->model('user_options_model');
$this->user_options_model->set_option('LogbookAdvanced', 'LogbookAdvanced', $obj);
$this->user_options_model->set_option('LogbookAdvancedMap', 'gridsquare_layer', array('boolean' => xss_clean($this->input->post('gridsquare_layer'))));
$this->user_options_model->set_option('LogbookAdvancedMap', 'path_lines', array('boolean' => xss_clean($this->input->post('path_lines'))));
$this->user_options_model->set_option('LogbookAdvancedMap', 'cqzones_layer', array('boolean' => xss_clean($this->input->post('cqzone_layer'))));
$this->user_options_model->set_option('LogbookAdvancedMap', 'ituzones_layer', array('boolean' => xss_clean($this->input->post('ituzone_layer'))));
$this->user_options_model->set_option('LogbookAdvancedMap', 'nightshadow_layer', array('boolean' => xss_clean($this->input->post('nightshadow_layer'))));
}
}

View File

@@ -25,6 +25,12 @@ if (!isset($current_opts->operator)) {
echo "\nvar o_template = { operator: {show: 'true'}};";
echo "\nuser_options={...user_options, ...o_template}";
}
foreach ($mapoptions as $mo) {
if ($mo != null) {
echo "var " . $mo->option_name . "=" . $mo->option_value . ";";
}
}
?>
</script>
<style>

View File

@@ -1,3 +1,15 @@
<div class="tabs">
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="logbook-tab" data-bs-toggle="tab" href="#logbooktab" role="tab" aria-controls="home" aria-selected="true">Logbook</a>
</li>
<li class="nav-item">
<a class="nav-link" id="map-tab" data-bs-toggle="tab" href="#maptab" role="tab" aria-controls="map" aria-selected="false">Map</a>
</li>
</ul>
</div>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="logbooktab" role="tabpanel" aria-labelledby="logbook-tab">
<table style="width:100%" class="table-sm table table-hover table-striped table-condensed text-start" id="useroptions">
<thead>
<tr>
@@ -96,3 +108,37 @@
</tr>
</tbody>
</table>
</div>
<div class="tab-pane fade show" id="maptab" role="tabpanel" aria-labelledby="map-tab">
<table style="width:100%" class="table-sm table table-hover table-striped table-condensed text-start" id="mapoptions">
<thead>
<tr>
<th class="text-start">Layer</th>
<th>Default on</th>
</tr>
</thead>
<tbody>
<tr>
<td>Path lines</td>
<td><div class="form-check"><input class="form-check-input" name="pathlines" type="checkbox" <?php if (($mapoptions['path_lines']->option_value ?? "false") == "true") { echo 'checked'; } ?>></div></td>
</tr>
<tr>
<td>Gridsquares</td>
<td><div class="form-check"><input class="form-check-input" name="gridsquareoverlay" type="checkbox" <?php if (($mapoptions['gridsquare_layer']->option_value ?? "false") == "true") { echo 'checked'; } ?>></div></td>
</tr>
<tr>
<td>CQ Zones</td>
<td><div class="form-check"><input class="form-check-input" name="cqzones" type="checkbox" <?php if (($mapoptions['cqzones_layer']->option_value ?? "false") == "true") { echo 'checked'; } ?>></div></td>
</tr>
<tr>
<td>ITU Zones</td>
<td><div class="form-check"><input class="form-check-input" name="ituzones" type="checkbox" <?php if (($mapoptions['ituzones_layer']->option_value ?? "false") == "true") { echo 'checked'; } ?>></div></td>
</tr>
<tr>
<td>Night Shadow</td>
<td><div class="form-check"><input class="form-check-input" name="nightshadow" type="checkbox" <?php if (($mapoptions['nightshadow_layer']->option_value ?? "false") == "true") { echo 'checked'; } ?>></div></td>
</tr>
</tbody>
</table>
</div>
</div>

View File

@@ -985,7 +985,7 @@ function loadMap(data, iconsList) {
},
});
L.tileLayer(
var osm = L.tileLayer(
osmUrl,
{
attribution: '&copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
@@ -997,9 +997,6 @@ function loadMap(data, iconsList) {
map.setView([30, 0], 1.5);
var osm = new L.TileLayer(osmUrl, {minZoom: 1, maxZoom: 9, attribution: osmAttrib});
var redIcon = L.icon({
iconUrl: icon_dot_url,
iconSize: [10, 10], // size of the icon
@@ -1067,18 +1064,18 @@ function loadMap(data, iconsList) {
legend.onAdd = function(map) {
var div = L.DomUtil.create("div", "legend");
div.innerHTML += '<div>' + counter + " QSOs plotted</div>";
div.innerHTML += '<input id="pathlines" type="checkbox" onclick="toggleFunction(this.checked)" checked="checked" style="outline: none;"><span> Path lines</span><br>';
div.innerHTML += '<input id="gridsquares" type="checkbox" onclick="toggleGridsquares(this.checked)" checked="checked" style="outline: none;"><span> Gridsquares</span><br>';
div.innerHTML += '<input id="gridsquares" type="checkbox" onclick="toggleCqZones(this.checked)" style="outline: none;"><span> CQ Zones</span><br>';
div.innerHTML += '<input id="gridsquares" type="checkbox" onclick="toggleItuZones(this.checked)" style="outline: none;"><span> ITU Zones</span><br>';
div.innerHTML += '<input id="gridsquares" type="checkbox" onclick="toggleNightShadow(this.checked)" style="outline: none;"><span> Show night shadow</span>';
div.innerHTML += '<input type="checkbox" onclick="toggleFunction(this.checked)" ' + (typeof path_lines !== 'undefined' && path_lines ? 'checked' : '') + ' style="outline: none;"><span> Path lines</span><br>';
div.innerHTML += '<input type="checkbox" onclick="toggleGridsquares(this.checked)" ' + (typeof gridsquare_layer !== 'undefined' && gridsquare_layer ? 'checked' : '') + ' style="outline: none;"><span> Gridsquares</span><br>';
div.innerHTML += '<input type="checkbox" onclick="toggleCqZones(this.checked)" ' + (typeof cqzones_layer !== 'undefined' && cqzones_layer ? 'checked' : '') + ' style="outline: none;"><span> CQ Zones</span><br>';
div.innerHTML += '<input type="checkbox" onclick="toggleItuZones(this.checked)" ' + (typeof ituzones_layer !== 'undefined' && ituzones_layer ? 'checked' : '') + ' style="outline: none;"><span> ITU Zones</span><br>';
div.innerHTML += '<input type="checkbox" onclick="toggleNightShadow(this.checked)" ' + (typeof nightshadow_layer !== 'undefined' && nightshadow_layer ? 'checked' : '') + ' style="outline: none;"><span> Night shadow</span>';
return div;
};
legend.addTo(map);
maidenhead = L.maidenheadqrb().addTo(map);
nightlayer = L.terminator().addTo(map);
map.fitBounds(bounds);
@@ -1095,6 +1092,36 @@ function loadMap(data, iconsList) {
}).addTo(map);
map.on('mousemove', onMapMove);
if (typeof gridsquare_layer !== 'undefined') {
toggleGridsquares(gridsquare_layer);
} else {
toggleGridsquares(false); // Set default value to false if gridsquare_layer is not defined
}
if (typeof path_lines !== 'undefined') {
toggleFunction(path_lines);
} else {
toggleFunction(false); // Set default value to false if gridsquare_layer is not defined
}
if (typeof cqzones_layer !== 'undefined') {
toggleGridsquares(cqzones_layer);
} else {
toggleGridsquares(false); // Set default value to false if gridsquare_layer is not defined
}
if (typeof ituzones_layer !== 'undefined') {
toggleItuZones(ituzones_layer);
} else {
toggleItuZones(false); // Set default value to false if gridsquare_layer is not defined
}
if (typeof nightshadow_layer !== 'undefined') {
toggleNightShadow(nightshadow_layer);
} else {
toggleNightShadow(false); // Set default value to false if gridsquare_layer is not defined
}
}
function createContentMessage(qso) {
@@ -1182,6 +1209,11 @@ function loadMap(data, iconsList) {
iota: $('input[name="iota"]').is(':checked') ? true : false,
pota: $('input[name="pota"]').is(':checked') ? true : false,
operator: $('input[name="operator"]').is(':checked') ? true : false,
gridsquare_layer: $('input[name="gridsquareoverlay"]').is(':checked') ? true : false,
path_lines: $('input[name="pathlines"]').is(':checked') ? true : false,
cqzone_layer: $('input[name="cqzones"]').is(':checked') ? true : false,
ituzone_layer: $('input[name="ituzones"]').is(':checked') ? true : false,
nightshadow_layer: $('input[name="nightshadow"]').is(':checked') ? true : false,
},
success: function(data) {
$('#saveButton').prop("disabled", false);
@@ -1350,7 +1382,9 @@ function loadMap(data, iconsList) {
zonemarkers.forEach(function (item) {
map.removeLayer(item);
});
map.removeLayer(geojson);
if (geojson != undefined) {
map.removeLayer(geojson);
}
} else {
geojson = L.geoJson(zonestuff, {style: style}).addTo(map);
for (var i = 0; i < cqzonenames.length; i++) {
@@ -1375,7 +1409,9 @@ function loadMap(data, iconsList) {
ituzonemarkers.forEach(function (item) {
map.removeLayer(item);
});
map.removeLayer(itugeojson);
if (itugeojson != undefined) {
map.removeLayer(itugeojson);
}
} else {
itugeojson = L.geoJson(ituzonestuff, {style: style}).addTo(map);
for (var i = 0; i < ituzonenames.length; i++) {
@@ -1399,7 +1435,7 @@ function loadMap(data, iconsList) {
if(!bool) {
map.removeLayer(nightlayer);
} else {
nightlayer = L.terminator().addTo(map);
nightlayer.addTo(map);
}
}