From fc95719f2e8e6cd45356ac899851c5718b5bd7f8 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Sat, 2 Jul 2016 17:11:33 +0100 Subject: [PATCH] Reinstate selecting aircraft by clicking on their icons. --- public_html/planeObject.js | 1 + public_html/script.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/public_html/planeObject.js b/public_html/planeObject.js index 92b0f9b..9a4d556 100644 --- a/public_html/planeObject.js +++ b/public_html/planeObject.js @@ -404,6 +404,7 @@ PlaneObject.prototype.updateMarker = function(moved) { } } else { this.marker = new ol.Feature(new ol.geom.Point(ol.proj.fromLonLat(this.position))); + this.marker.hex = this.icao; this.marker.setStyle(this.markerStyle); PlaneIconFeatures.push(this.marker); diff --git a/public_html/script.js b/public_html/script.js index d68a7df..ea9de91 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -390,6 +390,25 @@ function initialize_map() { localStorage['ZoomLvl'] = OLMap.getView().getZoom(); }); + OLMap.addInteraction(new ol.interaction.Pointer({ + handleDownEvent: function(evt) { + console.log("down event"); + var hex = evt.map.forEachFeatureAtPixel(evt.pixel, + function(feature, layer) { + return feature.hex; + }, + null, + function(layer) { + return (layer === iconsLayer); + }, + null); + if (hex) { + selectPlaneByHex(hex); + } + return false; + } + })); + // Add home marker if requested if (SitePosition) { console.log("setting up site position");