From 4842b8a06859dde729f946c7a3f5ba86ee1b7357 Mon Sep 17 00:00:00 2001 From: phl0 Date: Fri, 17 Jan 2025 12:46:29 +0100 Subject: [PATCH] Add Maidenhead grid to flightpath map --- application/controllers/Satellite.php | 1 + assets/js/leaflet/L.Maidenhead.js | 8 ++++---- assets/js/sections/flightpath.js | 2 ++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/application/controllers/Satellite.php b/application/controllers/Satellite.php index 561c43b19..ed57aa1c6 100644 --- a/application/controllers/Satellite.php +++ b/application/controllers/Satellite.php @@ -187,6 +187,7 @@ class Satellite extends CI_Controller { 'assets/js/sections/three-orbit-controls.js?' . filemtime(realpath(__DIR__ . "/../../assets/js/sections/three-orbit-controls.js")), 'assets/js/sections/satellite_functions.js?' . filemtime(realpath(__DIR__ . "/../../assets/js/sections/satellite_functions.js")), 'assets/js/sections/flightpath.js?' . filemtime(realpath(__DIR__ . "/../../assets/js/sections/flightpath.js")), + 'assets/js/leaflet/L.Maidenhead.js', ]; $homegrid = explode(',', $this->stations->find_gridsquare()); diff --git a/assets/js/leaflet/L.Maidenhead.js b/assets/js/leaflet/L.Maidenhead.js index dad24553c..4595e8a33 100644 --- a/assets/js/leaflet/L.Maidenhead.js +++ b/assets/js/leaflet/L.Maidenhead.js @@ -37,8 +37,8 @@ L.Maidenhead = L.LayerGroup.extend({ redraw: function () { var d3 = new Array(20,10,10,10,10,10,1 ,1 ,1 ,1 ,1/24,1/24,1/24,1/24,1/24,1/240,1/240,1/240,1/240,1/240/24,1/240/24 ); var lat_cor = new Array(0 ,8 ,8 ,8 ,10,14,6 ,8 ,8 ,8 ,1.4 ,2.5 ,3 ,3.5 ,4 ,4 ,3.5 ,3.5 ,3 ,1.8 ,1.6 ); - var bounds = map.getBounds(); - var zoom = map.getZoom(); + var bounds = this._map.getBounds(); + var zoom = this._map.getZoom(); var unit = d3[zoom]; var lcor = lat_cor[zoom]; var w = bounds.getWest(); @@ -67,7 +67,7 @@ L.Maidenhead = L.LayerGroup.extend({ _getLabel: function(lon,lat) { var title_size = new Array(0 ,10,12,16,20,26,15,16,24,36,12 ,14 ,20 ,36 ,60 ,12 ,20 ,36 ,60 ,12 ,24 ); - var zoom = map.getZoom(); + var zoom = this._map.getZoom(); var size = title_size[zoom]+'px'; var title = '' + this._getLocator(lon,lat) + ''; var myIcon = L.divIcon({className: 'my-div-icon', html: title}); @@ -83,7 +83,7 @@ L.Maidenhead = L.LayerGroup.extend({ var locator = ""; var x = lon; var y = lat; - var precision = d4[map.getZoom()]; + var precision = d4[this._map.getZoom()]; while (x < -180) {x += 360;} while (x > 180) {x -=360;} x = x + 180; diff --git a/assets/js/sections/flightpath.js b/assets/js/sections/flightpath.js index 24145ea92..66ffa8706 100644 --- a/assets/js/sections/flightpath.js +++ b/assets/js/sections/flightpath.js @@ -345,6 +345,8 @@ var sats = (function (L, d3, satelliteJs) { legend.addTo(leafletMap); + var maidenhead = L.maidenhead().addTo(leafletMap); + attributionControl = L.control.attribution({ prefix: '' }).addTo(leafletMap);