From 07d194bbd51cf8a5db233966c404579e9debefc3 Mon Sep 17 00:00:00 2001 From: antirez Date: Sun, 2 Feb 2020 23:26:08 +0100 Subject: [PATCH] OSM: ability to select a plane. --- gmap.html | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/gmap.html b/gmap.html index e8bde26..aba4997 100644 --- a/gmap.html +++ b/gmap.html @@ -62,20 +62,12 @@ he = '
✈️
'; var icon = L.divIcon({html: he, className: 'plane-icon'}); return icon; -// return { -// strokeWeight: (selected ? 2 : 1), -// path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW, -// scale: 5, -// fillColor: 'rgb('+r+','+g+','+b+')', -// fillOpacity: 0.9, -// rotation: plane.track -// }; } - function selectPlane() { - if (!Planes[this.planehex]) return; + function selectPlane(planehex) { + if (!Planes[planehex]) return; var old = Selected; - Selected = this.planehex; + Selected = planehex; if (Planes[old]) { /* Remove the highlight in the previously selected plane. */ Planes[old].marker.setIcon(getIconForPlane(Planes[old])); @@ -130,12 +122,11 @@ } else { var icon = getIconForPlane(plane); var marker = L.marker([plane.lat, plane.lon], {icon: icon}).addTo(Map); + var hex = plane.hex; + marker.on('click',function () {selectPlane(hex)}); plane.marker = marker; marker.planehex = plane.hex; Planes[plane.hex] = plane; - - /* Trap clicks for this marker. */ - // FIXME: google.maps.event.addListener(marker, 'click', selectPlane); } // FIXME: Set the title