OSM: ability to select a plane.

This commit is contained in:
antirez 2020-02-02 23:26:08 +01:00
parent e328c75010
commit 07d194bbd5

View File

@ -62,20 +62,12 @@
he = '<div style="transform: rotate(-'+rotation+'deg);">✈️</div>'; he = '<div style="transform: rotate(-'+rotation+'deg);">✈️</div>';
var icon = L.divIcon({html: he, className: 'plane-icon'}); var icon = L.divIcon({html: he, className: 'plane-icon'});
return 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() { function selectPlane(planehex) {
if (!Planes[this.planehex]) return; if (!Planes[planehex]) return;
var old = Selected; var old = Selected;
Selected = this.planehex; Selected = planehex;
if (Planes[old]) { if (Planes[old]) {
/* Remove the highlight in the previously selected plane. */ /* Remove the highlight in the previously selected plane. */
Planes[old].marker.setIcon(getIconForPlane(Planes[old])); Planes[old].marker.setIcon(getIconForPlane(Planes[old]));
@ -130,12 +122,11 @@
} else { } else {
var icon = getIconForPlane(plane); var icon = getIconForPlane(plane);
var marker = L.marker([plane.lat, plane.lon], {icon: icon}).addTo(Map); 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; plane.marker = marker;
marker.planehex = plane.hex; marker.planehex = plane.hex;
Planes[plane.hex] = plane; Planes[plane.hex] = plane;
/* Trap clicks for this marker. */
// FIXME: google.maps.event.addListener(marker, 'click', selectPlane);
} }
// FIXME: Set the title // FIXME: Set the title