From 115a77445e2eb851ee3348cecd8527d7588a90ab Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 3 Feb 2020 23:37:18 +0100 Subject: [PATCH] OSM: create closure for selectPlane callback. --- gmap.html | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/gmap.html b/gmap.html index aba4997..3b78a17 100644 --- a/gmap.html +++ b/gmap.html @@ -59,7 +59,13 @@ var he = document.createElement("P"); he.innerHTML = '>'; var rotation = 45+360-plane.track; - he = '
✈️
'; + var selhtml = ''; + if (Selected == plane.hex) { + selhtml = 'border:1px dotted #0000aa; border-radius:10px;'; + } else { + selhtml = ''; + } + he = '
✈️
'; var icon = L.divIcon({html: he, className: 'plane-icon'}); return icon; } @@ -75,6 +81,12 @@ Planes[Selected].marker.setIcon(getIconForPlane(Planes[Selected])); refreshSelectedInfo(); } + + function selectPlaneCallback(hex) { + return function() { + return selectPlane(hex); + } + } function refreshGeneralInfo() { var i = document.getElementById('geninfo'); @@ -123,7 +135,7 @@ 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)}); + marker.on('click',selectPlaneCallback(plane.hex)); plane.marker = marker; marker.planehex = plane.hex; Planes[plane.hex] = plane;