var osmUrl = $('#dxccmapjs').attr("tileUrl"); function load_dxcc_map() { $('.nav-tabs a[href="#dxccmaptab"]').tab('show'); $.ajax({ url: base_url + 'index.php/awards/dxcc_map', type: 'post', data: { band: $('#band2').val(), mode: $('#mode').val(), worked: +$('#worked').prop('checked'), confirmed: +$('#confirmed').prop('checked'), notworked: +$('#notworked').prop('checked'), qsl: +$('#qsl').prop('checked'), lotw: +$('#lotw').prop('checked'), includedeleted: +$('#includedeleted').prop('checked'), Africa: +$('#Africa').prop('checked'), Asia: +$('#Asia').prop('checked'), Europe: +$('#Europe').prop('checked'), NorthAmerica: +$('#NorthAmerica').prop('checked'), SouthAmerica: +$('#SouthAmerica').prop('checked'), Oceania: +$('#Oceania').prop('checked'), Antarctica: +$('#Antarctica').prop('checked'), }, success: function(data) { load_dxcc_map2(data, worked, confirmed, notworked); }, error: function() { }, }); } function load_dxcc_map2(data, worked, confirmed, notworked) { // If map is already initialized var container = L.DomUtil.get('dxccmap'); if(container != null){ container._leaflet_id = null; container.remove(); $("#dxccmaptab").append('
'); } var map = L.map('dxccmap'); L.tileLayer( osmUrl, { attribution: '© OpenStreetMap contributors, CC-BY-SA', maxZoom: 18 } ).addTo(map); var notworkedcount = data.length; var confirmedcount = 0; var workednotconfirmedcount = 0; for (var i = 0; i < data.length; i++) { var D = data[i]; if (D['status'] != 'x') { var mapColor = 'red'; if (D['status'] == 'C') { mapColor = 'green'; if (confirmed != '0') { addMarker(L, D, mapColor, map); confirmedcount++; notworkedcount--; } } if (D['status'] == 'W') { mapColor = 'orange'; if (worked != '0') { 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 += "