OSM: create closure for selectPlane callback.
This commit is contained in:
parent
db9f5f34a3
commit
115a77445e
16
gmap.html
16
gmap.html
@ -59,7 +59,13 @@
|
|||||||
var he = document.createElement("P");
|
var he = document.createElement("P");
|
||||||
he.innerHTML = '>';
|
he.innerHTML = '>';
|
||||||
var rotation = 45+360-plane.track;
|
var rotation = 45+360-plane.track;
|
||||||
he = '<div style="transform: rotate(-'+rotation+'deg);">✈️</div>';
|
var selhtml = '';
|
||||||
|
if (Selected == plane.hex) {
|
||||||
|
selhtml = 'border:1px dotted #0000aa; border-radius:10px;';
|
||||||
|
} else {
|
||||||
|
selhtml = '';
|
||||||
|
}
|
||||||
|
he = '<div style="transform: rotate(-'+rotation+'deg); '+selhtml+'">✈️</div>';
|
||||||
var icon = L.divIcon({html: he, className: 'plane-icon'});
|
var icon = L.divIcon({html: he, className: 'plane-icon'});
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
@ -75,6 +81,12 @@
|
|||||||
Planes[Selected].marker.setIcon(getIconForPlane(Planes[Selected]));
|
Planes[Selected].marker.setIcon(getIconForPlane(Planes[Selected]));
|
||||||
refreshSelectedInfo();
|
refreshSelectedInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function selectPlaneCallback(hex) {
|
||||||
|
return function() {
|
||||||
|
return selectPlane(hex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function refreshGeneralInfo() {
|
function refreshGeneralInfo() {
|
||||||
var i = document.getElementById('geninfo');
|
var i = document.getElementById('geninfo');
|
||||||
@ -123,7 +135,7 @@
|
|||||||
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;
|
var hex = plane.hex;
|
||||||
marker.on('click',function () {selectPlane(hex)});
|
marker.on('click',selectPlaneCallback(plane.hex));
|
||||||
plane.marker = marker;
|
plane.marker = marker;
|
||||||
marker.planehex = plane.hex;
|
marker.planehex = plane.hex;
|
||||||
Planes[plane.hex] = plane;
|
Planes[plane.hex] = plane;
|
||||||
|
Loading…
Reference in New Issue
Block a user