| 
									
										
										
										
											2018-11-25 22:21:12 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var map; | 
					
						
							|  |  |  | var ajaxRequest; | 
					
						
							|  |  |  | var plotlist; | 
					
						
							|  |  |  | var plotlayers=[]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-15 23:59:27 +08:00
										 |  |  | var greenIcon = L.icon({ | 
					
						
							|  |  |  |     iconUrl: icon_dot_url, | 
					
						
							|  |  |  |     iconSize:     [10, 10], // size of the icon
 | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-23 05:33:32 +08:00
										 |  |  | var osmUrl = $('#leafembed').attr("tileUrl"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-10 02:01:04 +08:00
										 |  |  | function initmap(ShowGrid = 'No', MapTag = 'map') { | 
					
						
							| 
									
										
										
										
											2018-11-25 22:21:12 +08:00
										 |  |  |     // set up AJAX request
 | 
					
						
							|  |  |  |     ajaxRequest=getXmlHttpObject(); | 
					
						
							|  |  |  |     if (ajaxRequest==null) { | 
					
						
							|  |  |  |         alert ("This browser does not support HTTP Request"); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     // set up the map
 | 
					
						
							| 
									
										
										
										
											2022-03-10 02:01:04 +08:00
										 |  |  |     map = new L.Map(MapTag); | 
					
						
							| 
									
										
										
										
											2018-11-25 22:21:12 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // create the tile layer with correct attribution
 | 
					
						
							|  |  |  |     var osmAttrib='Map data © <a href="https://openstreetmap.org">OpenStreetMap</a> contributors'; | 
					
						
							|  |  |  |     var osm = new L.TileLayer(osmUrl, {minZoom: 1, maxZoom: 9, attribution: osmAttrib});         | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-04 22:09:51 +08:00
										 |  |  | 	var printer = L.easyPrint({ | 
					
						
							|  |  |  | 		tileLayer: osm, | 
					
						
							|  |  |  | 		sizeModes: ['Current'], | 
					
						
							|  |  |  | 		filename: 'myMap', | 
					
						
							|  |  |  | 		exportOnly: true, | 
					
						
							|  |  |  | 		hideControlContainer: true | 
					
						
							|  |  |  | 	}).addTo(map); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-25 22:21:12 +08:00
										 |  |  |     // start the map in South-East England
 | 
					
						
							| 
									
										
										
										
											2018-11-27 04:24:14 +08:00
										 |  |  |     map.setView(new L.LatLng(q_lat, q_lng), q_zoom); | 
					
						
							| 
									
										
										
										
											2019-06-25 01:21:02 +08:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	map.addLayer(osm); | 
					
						
							| 
									
										
										
										
											2018-11-25 22:21:12 +08:00
										 |  |  | 	askForPlots(); | 
					
						
							| 
									
										
										
										
											2019-06-25 01:21:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-25 22:21:12 +08:00
										 |  |  | 	map.on('moveend', onMapMove); | 
					
						
							| 
									
										
										
										
											2019-06-25 00:32:22 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-25 01:21:02 +08:00
										 |  |  | 	if(ShowGrid == "Yes") { | 
					
						
							|  |  |  | 		var maidenhead = L.maidenhead().addTo(map); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	var layerControl = new L.Control.Layers(null, { | 
					
						
							|  |  |  |     'Gridsquares': maidenhead = L.maidenhead() | 
					
						
							|  |  |  | 	}).addTo(map); | 
					
						
							| 
									
										
										
										
											2018-11-25 22:21:12 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function getXmlHttpObject() { | 
					
						
							|  |  |  | 	if (window.XMLHttpRequest) { return new XMLHttpRequest(); } | 
					
						
							|  |  |  | 	if (window.ActiveXObject)  { return new ActiveXObject("Microsoft.XMLHTTP"); } | 
					
						
							|  |  |  | 	return null; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function askForPlots() { | 
					
						
							|  |  |  |     // request the marker info with AJAX for the current bounds
 | 
					
						
							|  |  |  |     ajaxRequest.onreadystatechange = stateChanged; | 
					
						
							|  |  |  |     ajaxRequest.open('GET', qso_loc, true); | 
					
						
							|  |  |  |     ajaxRequest.send(null); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function stateChanged() { | 
					
						
							|  |  |  | 	// if AJAX returned a list of markers, add them to the map
 | 
					
						
							|  |  |  | 	if (ajaxRequest.readyState==4) { | 
					
						
							|  |  |  | 		//use the info here that was returned
 | 
					
						
							|  |  |  | 		if (ajaxRequest.status==200) { | 
					
						
							|  |  |  |             plotlist=eval("(" + ajaxRequest.responseText + ")"); | 
					
						
							|  |  |  |             plotlist = plotlist['markers']; | 
					
						
							|  |  |  | 			removeMarkers(); | 
					
						
							|  |  |  | 			for (i=0;i<plotlist.length;i++) { | 
					
						
							|  |  |  | 				var plotll = new L.LatLng(plotlist[i].lat,plotlist[i].lng, true); | 
					
						
							| 
									
										
										
										
											2020-06-15 23:59:27 +08:00
										 |  |  | 				var plotmark = new L.Marker(plotll, {icon: greenIcon}); | 
					
						
							| 
									
										
										
										
											2018-11-25 22:21:12 +08:00
										 |  |  | 				plotmark.data=plotlist[i]; | 
					
						
							|  |  |  | 				map.addLayer(plotmark); | 
					
						
							|  |  |  | 				plotmark.bindPopup("<h3>"+plotlist[i].label+"</h3>"+plotlist[i].html); | 
					
						
							|  |  |  | 				plotlayers.push(plotmark); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function removeMarkers() { | 
					
						
							|  |  |  | 	for (i=0;i<plotlayers.length;i++) { | 
					
						
							|  |  |  | 		map.removeLayer(plotlayers[i]); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	plotlayers=[]; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function onMapMove(e) { | 
					
						
							|  |  |  |     askForPlots(); | 
					
						
							|  |  |  | } |