From fd7d79eb02f07bfc3381e2cba365c1ae6e650cf9 Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Mon, 6 May 2024 00:22:12 +0200 Subject: [PATCH] mouseover handler change in preparation for ais tooltips --- html/layers.js | 4 ++-- html/script.js | 25 +++++++++++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/html/layers.js b/html/layers.js index 7248f86..bf715e4 100644 --- a/html/layers.js +++ b/html/layers.js @@ -844,7 +844,7 @@ function createBaseLayers() { 13: { size: [20, 20], offset: [40, 40], comment: 'CLASS_SARTEPIRB' } }; - var aiscatcher_overlay = new ol.layer.Vector({ + g.aiscatcherLayer = new ol.layer.Vector({ type: 'overlay', title: "aiscatcher", name: "aiscatcher", @@ -878,7 +878,7 @@ function createBaseLayers() { }); } }); - world.push(aiscatcher_overlay); + world.push(g.aiscatcherLayer); } layers.push(new ol.layer.Group({ diff --git a/html/script.js b/html/script.js index e7fe4d1..1eba353 100644 --- a/html/script.js +++ b/html/script.js @@ -2375,9 +2375,7 @@ function ol_map_init() { }); // show the hover box - if (!globeIndex && zoomLvl > 5.5 && enableMouseover) { - OLMap.on('pointermove', onPointermove); - } + checkPointermove(); } // Initalizes the map and starts up our timers to call various functions @@ -5499,17 +5497,32 @@ function onPointermove(evt) { } function highlight(evt) { - const hex = evt.map.forEachFeatureAtPixel(evt.pixel, + const feature = evt.map.forEachFeatureAtPixel(evt.pixel, function(feature, layer) { - return feature.hex; + return feature; }, { layerFilter: function(layer) { - return (layer == iconLayer || layer == webglLayer); + return (layer == iconLayer || layer == webglLayer || layer == g.aiscatcherLayer); }, hitTolerance: 5 * globalScale, } ); + if (!feature) { + HighlightedPlane = null; + refreshHighlighted(); + return; + } + const hex = feature.hex; + + const values = feature.values_; + const mmsi = values ? values.mmsi : null; + if (hex) { + //console.log(hex); + } + if (mmsi) { + //console.log(mmsi); + } if (HighlightedPlane && hex == HighlightedPlane.icao) return;