Added onclick for map so that it returns the gridsquare of the mouse click thinking useful for a popup of the people worked in the square

这个提交包含在:
Peter Goodhall 2020-03-14 22:09:25 +00:00
父节点 a0bdf32729
当前提交 a05344a0e3
共有 2 个文件被更改,包括 43 次插入0 次删除

查看文件

@ -879,6 +879,17 @@ $(document).ready(function(){
var maidenhead = L.maidenhead().addTo(map); var maidenhead = L.maidenhead().addTo(map);
map.on('click', onMapClick);
function onMapClick(event) {
var LatLng = event.latlng;
var lat = LatLng.lat;
var lng = LatLng.lng;
var locator = LatLng2Loc(lat,lng, 10);
console.log(locator);
};
<?php if ($this->uri->segment(1) == "gridsquares" && $this->uri->segment(2) == "band") { ?> <?php if ($this->uri->segment(1) == "gridsquares" && $this->uri->segment(2) == "band") { ?>
var bands_available = <?php echo $bands_available; ?>; var bands_available = <?php echo $bands_available; ?>;

查看文件

@ -55,4 +55,36 @@ function frequencyToBand(frequency) {
else if(result >= 10125000000 && result <= 10525000000) { else if(result >= 10125000000 && result <= 10525000000) {
return '3cm'; return '3cm';
} }
}
function LatLng2Loc(y, x, num) {
if (x<-180) {x=x+360;}
if (x>180) {x=x-360;}
var yqth, yi, yk, ydiv, yres, ylp, y;
var ycalc = new Array(0,0,0);
var yn = new Array(0,0,0,0,0,0,0);
var ydiv_arr=new Array(10, 1, 1/24, 1/240, 1/240/24);
ycalc[0] = (x + 180)/2;
ycalc[1] = y + 90;
for (yi = 0; yi < 2; yi++) {
for (yk = 0; yk < 5; yk++) {
ydiv = ydiv_arr[yk];
yres = ycalc[yi] / ydiv;
ycalc[yi] = yres;
if (ycalc[yi] > 0) ylp = Math.floor(yres); else ylp = Math.ceil(yres);
ycalc[yi] = (ycalc[yi] - ylp) * ydiv;
yn[2*yk + yi] = ylp;
}
}
var qthloc="";
if (num >= 2) qthloc+=String.fromCharCode(yn[0] + 0x41) + String.fromCharCode(yn[1] + 0x41);
if (num >= 4) qthloc+=String.fromCharCode(yn[2] + 0x30) + String.fromCharCode(yn[3] + 0x30);
if (num >= 6) qthloc+=String.fromCharCode(yn[4] + 0x41) + String.fromCharCode(yn[5] + 0x41);
if (num >= 8) qthloc+=' ' + String.fromCharCode(yn[6] + 0x30) + String.fromCharCode(yn[7] + 0x30);
if (num >= 10) qthloc+=String.fromCharCode(yn[8] + 0x61) + String.fromCharCode(yn[9] + 0x61);
return qthloc;
} }