[DXCC Mao] Fixed so that worked/confirmed/not worked works with map
这个提交包含在:
父节点
1b563b7eb0
当前提交
06028992aa
共有 2 个文件被更改,包括 69 次插入 和 47 次删除
|
|
@ -644,7 +644,7 @@ class Awards extends CI_Controller {
|
||||||
}
|
}
|
||||||
$newdxcc[$i]['lat'] = $dxcc->lat;
|
$newdxcc[$i]['lat'] = $dxcc->lat;
|
||||||
$newdxcc[$i]['long'] = $dxcc->long;
|
$newdxcc[$i]['long'] = $dxcc->long;
|
||||||
$newdxcc[$i++]['status'] = $this->returnStatus($dxcc_array[$dxcc->adif]);
|
$newdxcc[$i++]['status'] = isset($dxcc_array[$dxcc->adif]) ? $this->returnStatus($dxcc_array[$dxcc->adif]) : 'x';
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ function load_dxcc_map() {
|
||||||
Antarctica: +$('#Antarctica').prop('checked'),
|
Antarctica: +$('#Antarctica').prop('checked'),
|
||||||
},
|
},
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
load_dxcc_map2(data);
|
load_dxcc_map2(data, worked, confirmed, notworked);
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
|
|
||||||
|
|
@ -31,7 +31,7 @@ function load_dxcc_map() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function load_dxcc_map2(data) {
|
function load_dxcc_map2(data, worked, confirmed, notworked) {
|
||||||
|
|
||||||
// If map is already initialized
|
// If map is already initialized
|
||||||
var container = L.DomUtil.get('dxccmap');
|
var container = L.DomUtil.get('dxccmap');
|
||||||
|
|
@ -51,25 +51,64 @@ function load_dxcc_map2(data) {
|
||||||
}
|
}
|
||||||
).addTo(map);
|
).addTo(map);
|
||||||
|
|
||||||
var notworked = data.length;
|
var notworkedcount = data.length;
|
||||||
var confirmed = 0;
|
var confirmedcount = 0;
|
||||||
var workednotconfirmed = 0;
|
var workednotconfirmedcount = 0;
|
||||||
|
|
||||||
for (var i = 0; i < data.length; i++) {
|
for (var i = 0; i < data.length; i++) {
|
||||||
var D = data[i];
|
var D = data[i];
|
||||||
|
if (D['status'] != 'x') {
|
||||||
var mapColor = 'red';
|
var mapColor = 'red';
|
||||||
|
|
||||||
if (D['status'] == 'C') {
|
if (D['status'] == 'C') {
|
||||||
mapColor = 'green';
|
mapColor = 'green';
|
||||||
confirmed++;
|
if (confirmed != '0') {
|
||||||
notworked--;
|
addMarker(L, D, mapColor, map);
|
||||||
|
confirmedcount++;
|
||||||
|
notworkedcount--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (D['status'] == 'W') {
|
if (D['status'] == 'W') {
|
||||||
mapColor = 'orange';
|
mapColor = 'orange';
|
||||||
workednotconfirmed++;
|
if (worked != '0') {
|
||||||
notworked--;
|
addMarker(L, D, mapColor, map);
|
||||||
|
workednotconfirmedcount++;
|
||||||
|
notworkedcount--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Make a check here and hide what I don't want to show
|
||||||
|
if (notworked != '0') {
|
||||||
|
if (mapColor == 'red') {
|
||||||
|
addMarker(L, D, mapColor, map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*Legend specific*/
|
||||||
|
var legend = L.control({ position: "topright" });
|
||||||
|
|
||||||
|
if (notworked.checked == false) {
|
||||||
|
notworkedcount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
legend.onAdd = function(map) {
|
||||||
|
var div = L.DomUtil.create("div", "legend");
|
||||||
|
div.innerHTML += "<h4>Colors</h4>";
|
||||||
|
div.innerHTML += '<i style="background: green"></i><span>Confirmed ('+confirmedcount+')</span><br>';
|
||||||
|
div.innerHTML += '<i style="background: orange"></i><span>Worked not confirmed ('+workednotconfirmedcount+')</span><br>';
|
||||||
|
div.innerHTML += '<i style="background: red"></i><span>Not worked ('+notworkedcount+')</span><br>';
|
||||||
|
return div;
|
||||||
|
};
|
||||||
|
|
||||||
|
legend.addTo(map);
|
||||||
|
|
||||||
|
map.setView([20, 0], 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
function addMarker(L, D, mapColor, map) {
|
||||||
const markerHtmlStyles = `
|
const markerHtmlStyles = `
|
||||||
background-color: ${mapColor};
|
background-color: ${mapColor};
|
||||||
width: 1rem;
|
width: 1rem;
|
||||||
|
|
@ -95,23 +134,6 @@ function load_dxcc_map2(data) {
|
||||||
title: D['prefix'] + ' - ' + D['name'],
|
title: D['prefix'] + ' - ' + D['name'],
|
||||||
}
|
}
|
||||||
).addTo(map).on('click', onClick);
|
).addTo(map).on('click', onClick);
|
||||||
}
|
|
||||||
|
|
||||||
/*Legend specific*/
|
|
||||||
var legend = L.control({ position: "topright" });
|
|
||||||
|
|
||||||
legend.onAdd = function(map) {
|
|
||||||
var div = L.DomUtil.create("div", "legend");
|
|
||||||
div.innerHTML += "<h4>Colors</h4>";
|
|
||||||
div.innerHTML += '<i style="background: green"></i><span>Confirmed ('+confirmed+')</span><br>';
|
|
||||||
div.innerHTML += '<i style="background: orange"></i><span>Worked not confirmed ('+workednotconfirmed+')</span><br>';
|
|
||||||
div.innerHTML += '<i style="background: red"></i><span>Not worked ('+notworked+')</span><br>';
|
|
||||||
return div;
|
|
||||||
};
|
|
||||||
|
|
||||||
legend.addTo(map);
|
|
||||||
|
|
||||||
map.setView([20, 0], 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClick(e) {
|
function onClick(e) {
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用