| 
									
										
										
										
											2022-11-12 02:23:41 +08:00
										 |  |  | 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) { | 
					
						
							| 
									
										
										
										
											2022-11-23 00:51:31 +08:00
										 |  |  |             load_dxcc_map2(data, worked, confirmed, notworked); | 
					
						
							| 
									
										
										
										
											2022-11-12 02:23:41 +08:00
										 |  |  |         }, | 
					
						
							|  |  |  |         error: function() { | 
					
						
							|  |  |  |              | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-23 00:51:31 +08:00
										 |  |  | function load_dxcc_map2(data, worked, confirmed, notworked) { | 
					
						
							| 
									
										
										
										
											2022-11-12 02:23:41 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // If map is already initialized
 | 
					
						
							|  |  |  |     var container = L.DomUtil.get('dxccmap'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if(container != null){ | 
					
						
							|  |  |  |         container._leaflet_id = null; | 
					
						
							|  |  |  |         container.remove(); | 
					
						
							| 
									
										
										
										
											2023-12-09 17:44:26 +08:00
										 |  |  |         $("#dxccmaptab").append('<div id="dxccmap" class="map-leaflet" ></div>'); | 
					
						
							| 
									
										
										
										
											2022-11-12 02:23:41 +08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-19 23:58:29 +08:00
										 |  |  |     var map = new L.Map('dxccmap', { | 
					
						
							|  |  |  |         fullscreenControl: true, | 
					
						
							|  |  |  |         fullscreenControlOptions: { | 
					
						
							|  |  |  |           position: 'topleft' | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-12 02:23:41 +08:00
										 |  |  |     L.tileLayer( | 
					
						
							|  |  |  |         osmUrl, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             attribution: '© <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>', | 
					
						
							|  |  |  |             maxZoom: 18 | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     ).addTo(map); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-23 00:51:31 +08:00
										 |  |  |     var notworkedcount = data.length; | 
					
						
							|  |  |  |     var confirmedcount = 0; | 
					
						
							|  |  |  |     var workednotconfirmedcount = 0; | 
					
						
							| 
									
										
										
										
											2022-11-12 02:23:41 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     for (var i = 0; i < data.length; i++) { | 
					
						
							| 
									
										
										
										
											2022-11-23 00:51:31 +08:00
										 |  |  |         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); | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2022-11-12 02:23:41 +08:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2022-11-23 00:51:31 +08:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-11-12 02:23:41 +08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /*Legend specific*/ | 
					
						
							|  |  |  |     var legend = L.control({ position: "topright" }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-23 00:51:31 +08:00
										 |  |  |     if (notworked.checked == false) { | 
					
						
							|  |  |  |         notworkedcount = 0; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-12 02:23:41 +08:00
										 |  |  |     legend.onAdd = function(map) { | 
					
						
							|  |  |  |         var div = L.DomUtil.create("div", "legend"); | 
					
						
							|  |  |  |         div.innerHTML += "<h4>Colors</h4>"; | 
					
						
							| 
									
										
										
										
											2022-11-23 00:51:31 +08:00
										 |  |  |         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>'; | 
					
						
							| 
									
										
										
										
											2022-11-12 02:23:41 +08:00
										 |  |  |         return div; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     legend.addTo(map); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     map.setView([20, 0], 2); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-23 00:51:31 +08:00
										 |  |  | function addMarker(L, D, mapColor, map) { | 
					
						
							| 
									
										
										
										
											2022-11-24 21:37:33 +08:00
										 |  |  |     var title = '<span><font style="color: ' +mapColor+ '; text-shadow: 1px 0 #fff, -1px 0 #fff, 0 1px #fff, 0 -1px #fff, 1px 1px #fff, -1px -1px #fff, 1px -1px #fff, -1px 1px #fff;font-size: 14px; font-weight: 900;">' + D['prefix'] + '</font></span>'; | 
					
						
							|  |  |  |     var myIcon = L.divIcon({className: 'my-div-icon', html: title}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-23 00:51:31 +08:00
										 |  |  |     const markerHtmlStyles = `
 | 
					
						
							|  |  |  |     background-color: ${mapColor}; | 
					
						
							|  |  |  |     width: 1rem; | 
					
						
							|  |  |  |     height: 1rem; | 
					
						
							|  |  |  |     display: block; | 
					
						
							|  |  |  |     position: relative; | 
					
						
							|  |  |  |     border-radius: 3rem 3rem 0; | 
					
						
							|  |  |  |     transform: rotate(45deg); | 
					
						
							|  |  |  |     border: 1px solid #FFFFFF`
 | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |     const icon = L.divIcon({ | 
					
						
							|  |  |  |         className: "my-custom-pin", | 
					
						
							|  |  |  |         iconAnchor: [0, 24], | 
					
						
							|  |  |  |         labelAnchor: [-6, 0], | 
					
						
							|  |  |  |         popupAnchor: [0, -36], | 
					
						
							|  |  |  |         html: `<span style="${markerHtmlStyles}" />` | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     L.marker( | 
					
						
							|  |  |  |     [D['lat'], D['long']], { | 
					
						
							| 
									
										
										
										
											2022-11-24 21:37:33 +08:00
										 |  |  |         icon: myIcon, | 
					
						
							| 
									
										
										
										
											2022-11-23 00:51:31 +08:00
										 |  |  |         adif: D['adif'], | 
					
						
							|  |  |  |         title: D['prefix'] + ' - ' + D['name'], | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     ).addTo(map).on('click', onClick); | 
					
						
							| 
									
										
										
										
											2022-11-24 21:37:33 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     L.marker( | 
					
						
							|  |  |  |         [D['lat'], D['long']], { | 
					
						
							|  |  |  |             icon: icon, | 
					
						
							|  |  |  |             adif: D['adif'], | 
					
						
							|  |  |  |             title: D['prefix'] + ' - ' + D['name'], | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         ).addTo(map).on('click', onClick); | 
					
						
							| 
									
										
										
										
											2022-11-23 00:51:31 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-12 02:23:41 +08:00
										 |  |  | function onClick(e) { | 
					
						
							|  |  |  |     var marker = e.target; | 
					
						
							| 
									
										
										
										
											2023-08-15 22:27:26 +08:00
										 |  |  |     displayContactsOnMap($("#dxccmap"),marker.options.adif, $('#band2').val(), $('#mode').val(), 'DXCC2'); | 
					
						
							| 
									
										
										
										
											2022-11-12 02:23:41 +08:00
										 |  |  | } |