Skip to content

Commit 1fd5c2f

Browse files
authored
Merge pull request #211 from LukePrior/testing
initial small icon support
2 parents 2568afb + 6ca370d commit 1fd5c2f

File tree

4 files changed

+121
-64
lines changed

4 files changed

+121
-64
lines changed

index.html

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ <h2>Contribute</h2>
129129
<div class="slimContainer">
130130
<h2><i class="icon-settings rfloat"></i>Settings</h2>
131131
<hr/>
132+
<h4>General</h4>
133+
<hr/>
132134
<div class="row option">
133135
<span><b>Interpolate gaps in telemetry</b></span>
134136
<div class="switch off" id="sw_interpolate">
@@ -164,6 +166,8 @@ <h2><i class="icon-settings rfloat"></i>Settings</h2>
164166
<input type="checkbox" id="opt_hide_timebox">
165167
</div>
166168
</div>
169+
<h4>Visibility</h4>
170+
<hr/>
167171
<div class="row option">
168172
<span><b>Hide receivers from the map</b></span>
169173
<div class="switch off" id="sw_hide_receivers">
@@ -186,14 +190,7 @@ <h2><i class="icon-settings rfloat"></i>Settings</h2>
186190
</div>
187191
</div>
188192
<div class="row option">
189-
<span><b>Highlight selected vehicle</b></span>
190-
<div class="switch off" id="sw_hilight_vehicle">
191-
<span class="thumb"></span>
192-
<input type="checkbox" id="opt_hilight_vehicle">
193-
</div>
194-
</div>
195-
<div class="row option">
196-
<span><b>Hide Horizon Rings</b></span>
193+
<span><b>Show Horizon Rings</b></span>
197194
<div class="switch off" id="sw_hide_horizon">
198195
<span class="thumb"></span>
199196
<input type="checkbox" id="opt_hide_horizon">
@@ -213,6 +210,22 @@ <h2><i class="icon-settings rfloat"></i>Settings</h2>
213210
<input type="checkbox" id="opt_layers_launches">
214211
</div>
215212
</div>
213+
<h4>Other</h4>
214+
<hr/>
215+
<div class="row option">
216+
<span><b>Highlight selected vehicle</b></span>
217+
<div class="switch off" id="sw_hilight_vehicle">
218+
<span class="thumb"></span>
219+
<input type="checkbox" id="opt_hilight_vehicle">
220+
</div>
221+
</div>
222+
<div class="row option">
223+
<span><b>Small icons</b></span>
224+
<div class="switch off" id="sw_small_icons">
225+
<span class="thumb"></span>
226+
<input type="checkbox" id="opt_small_icons">
227+
</div>
228+
</div>
216229
<h4>Overlays</h4>
217230
<hr/>
218231
<div class="row option">

js/app.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,7 @@ $(window).ready(function() {
722722
'#sw_hide_horizon',
723723
'#sw_hide_titles',
724724
'#sw_layers_launches',
725+
'#sw_small_icons',
725726
"#sw_nowelcome",
726727
"#sw_interpolate",
727728
];
@@ -802,12 +803,15 @@ $(window).ready(function() {
802803
break;
803804
case "opt_hide_horizon":
804805
if(on) {
805-
hideHorizonRings();
806+
showHorizonRings();
806807
}
807808
else {
808-
showHorizonRings();
809+
hideHorizonRings();
809810
}
810811
break;
812+
case "opt_small_icons":
813+
updateIconSize(on);
814+
break;
811815
case "opt_hide_titles":
812816
if(on) {
813817
hideTitles();

js/chasecar.lib.js

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ ChaseCar.updatePosition = function(callsign, position) {
4545

4646
ChaseCar.markRecovered = function(){
4747

48-
// Distance limits removed 2021-12-04
49-
//_run_checks = true;
50-
//_range_limit = 200000; // 200 km
48+
// Distance limits reinstated 2021-12-04
49+
_run_checks = true;
50+
_range_limit = 200000; // 200 km
5151

5252
// Get the serial number to be marked recovered
5353
_serial = $("#pr_serial").val().trim();
@@ -88,33 +88,31 @@ ChaseCar.markRecovered = function(){
8888
}
8989

9090
} else {
91-
// NOTE - Distance checks now removed.
92-
9391
// Sonde is on the map, so run some additional checks.
9492
_recov_lat = vehicles[_serial].curr_position['gps_lat'];
9593
_recov_lon = vehicles[_serial].curr_position['gps_lon'];
9694

97-
// // Now get the last position of the sonde.
98-
// _sonde = {
99-
// 'lat':_recov_lat,
100-
// 'lon':_recov_lon,
101-
// 'alt':0.0
102-
// };
103-
104-
// // Now get the chaser position.
105-
// _chaser = {
106-
// 'lat': parseFloat($('#cc_lat').text()),
107-
// 'lon': parseFloat($('#cc_lon').text()),
108-
// 'alt': 0.0
109-
// };
110-
111-
// // Calculate the distance from the sonde
112-
// _lookangles = calculate_lookangles(_chaser, _sonde);
113-
114-
// if( (_lookangles.range > _range_limit ) && _run_checks){
115-
// $('#pr_last_report').text("Outside distance limit.");
116-
// return;
117-
// }
95+
// Now get the last position of the sonde.
96+
_sonde = {
97+
'lat':_recov_lat,
98+
'lon':_recov_lon,
99+
'alt':0.0
100+
};
101+
102+
// Now get the chaser position.
103+
_chaser = {
104+
'lat': parseFloat($('#cc_lat').text()),
105+
'lon': parseFloat($('#cc_lon').text()),
106+
'alt': 0.0
107+
};
108+
109+
// Calculate the distance from the sonde
110+
_lookangles = calculate_lookangles(_chaser, _sonde);
111+
112+
if( (_lookangles.range > _range_limit ) && _run_checks){
113+
$('#pr_last_report').text("Outside distance limit.");
114+
return;
115+
}
118116

119117
if($("#sw_use_car_pos").hasClass('on')){
120118
_recov_lat = parseFloat($('#cc_lat').text());

js/tracker.js

Lines changed: 70 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ function load() {
715715

716716
map.on('zoomend', function() {
717717
//do check for horizon labels
718-
if (!offline.get("opt_hide_horizon")) {
718+
if (offline.get("opt_hide_horizon")) {
719719
for (key in vehicles) {
720720
if (vehicles[key]["vehicle_type"] == "balloon") {
721721
if (vehicles[key]["horizon_circle"]["_map"])
@@ -2699,6 +2699,10 @@ function drawLaunchPrediction(vcallsign) {
26992699
}
27002700

27012701
function redrawPrediction(vcallsign) {
2702+
var scale = 1;
2703+
if (offline.get("opt_small_icons")) {
2704+
scale = 0.5;
2705+
}
27022706
var vehicle = vehicles[vcallsign];
27032707
var data = vehicle.prediction.data;
27042708
if(data.warnings || data.errors) return;
@@ -2760,8 +2764,8 @@ function redrawPrediction(vcallsign) {
27602764
image_src = host_url + markers_url + "target-" + balloon_colors_name[vehicle.color_index] + ".png";
27612765
predictionIcon = new L.icon({
27622766
iconUrl: image_src,
2763-
iconSize: [20,20],
2764-
iconAnchor: [10, 10],
2767+
iconSize: [20*scale,20*scale],
2768+
iconAnchor: [10*scale, 10*scale],
27652769
});
27662770
vehicle.prediction_target = new L.Marker(latlng, {
27672771
zIndexOffset: Z_SHADOW,
@@ -2783,8 +2787,8 @@ function redrawPrediction(vcallsign) {
27832787
image_src = host_url + markers_url + "balloon-pop.png";
27842788
burstIcon = new L.icon({
27852789
iconUrl: image_src,
2786-
iconSize: [20,20],
2787-
iconAnchor: [10, 10],
2790+
iconSize: [20*scale,20*scale],
2791+
iconAnchor: [10*scale, 10*scale],
27882792
});
27892793
vehicle.prediction_burst = new L.Marker(latlng_burst, {
27902794
zIndexOffset: Z_SHADOW,
@@ -3263,6 +3267,10 @@ var array_unique = function(inarr) {
32633267

32643268
function addPosition(position) {
32653269
var vcallsign = position.vehicle;
3270+
var scale = 1
3271+
if (offline.get("opt_small_icons")) {
3272+
scale = 0.5;
3273+
}
32663274

32673275
// check if the vehicle is already in the list, if not create a new item
32683276
if(!vehicles.hasOwnProperty(vcallsign)) {
@@ -3283,8 +3291,8 @@ function addPosition(position) {
32833291
vehicle_type = "car";
32843292
color_index = car_index++ % car_colors.length;
32853293
image_src = host_url + markers_url + "car-" + car_colors[color_index] + ".png";
3286-
image_src_size = [55,25];
3287-
image_src_offset = [0,-25];
3294+
image_src_size = [55*scale,25*scale];
3295+
image_src_offset = [0*scale,-25*scale];
32883296

32893297
marker = new L.Marker(point, {
32903298
title: vcallsign,
@@ -3349,13 +3357,13 @@ function addPosition(position) {
33493357

33503358
image_src = host_url + markers_url + "balloon-" +
33513359
((vcallsign == "PIE") ? "rpi" : balloon_colors_name[color_index]) + ".png";
3352-
image_src_size = [46,84];
3353-
image_src_offset = [-35,-46];
3360+
image_src_size = [46*scale,84*scale];
3361+
image_src_offset = [-35*scale,-46*scale];
33543362

33553363
shadowIcon = new L.icon({
33563364
iconUrl: host_url + markers_url + "shadow.png",
3357-
iconSize: [24,16],
3358-
iconAnchor: [12, 8],
3365+
iconSize: [24*scale,16*scale],
3366+
iconAnchor: [12*scale, 8*scale],
33593367
});
33603368

33613369
marker_shadow = new L.Marker(point, {
@@ -3409,14 +3417,14 @@ function addPosition(position) {
34093417

34103418
img = new L.icon ({
34113419
iconUrl: host_url + markers_url + "payload-" + this.balloonColor + ".png",
3412-
iconSize: [17,18],
3413-
iconAnchor: [8,14],
3414-
tooltipAnchor: [0,-20],
3420+
iconSize: [17*scale,18*scale],
3421+
iconAnchor: [8*scale,14*scale],
3422+
tooltipAnchor: [0*scale,-20*scale],
34153423
});
34163424
} else {
34173425
map.addLayer(vehicle.marker.shadow);
34183426

3419-
if(offline.get('opt_hide_horizon') == false){
3427+
if(!offline.get('opt_hide_horizon') == false){
34203428
map.addLayer(vehicle.horizon_circle);
34213429
map.addLayer(vehicle.subhorizon_circle);
34223430
map.addLayer(vehicle.horizon_circle_title);
@@ -3426,16 +3434,16 @@ function addPosition(position) {
34263434
if(mode == "parachute") {
34273435
img = new L.icon ({
34283436
iconUrl: host_url + markers_url + "parachute-" + this.balloonColor + ".png",
3429-
iconSize: [46,84],
3430-
tooltipAnchor: [0,-98],
3431-
iconAnchor: [23,90],
3437+
iconSize: [46*scale,84*scale],
3438+
tooltipAnchor: [0*scale,-98*scale],
3439+
iconAnchor: [23*scale,90*scale],
34323440
});
34333441
} else {
34343442
img = new L.icon ({
34353443
iconUrl: host_url + markers_url + "balloon-" + this.balloonColor + ".png",
3436-
iconSize: [46,84],
3437-
tooltipAnchor: [0,-98],
3438-
iconAnchor: [23,90],
3444+
iconSize: [46*scale,84*scale],
3445+
tooltipAnchor: [0*scale,-98*scale],
3446+
iconAnchor: [23*scale,90*scale],
34393447
});
34403448
}
34413449
}
@@ -3490,7 +3498,7 @@ function addPosition(position) {
34903498
interactive: false,
34913499
});
34923500

3493-
if (!offline.get("opt_hide_horizon")) {
3501+
if (offline.get("opt_hide_horizon")) {
34943502
horizon_circle.addTo(map);
34953503
horizon_circle_title.addTo(map);
34963504
}
@@ -3522,7 +3530,7 @@ function addPosition(position) {
35223530
interactive: false,
35233531
});
35243532

3525-
if (!offline.get("opt_hide_horizon")) {
3533+
if (offline.get("opt_hide_horizon")) {
35263534
subhorizon_circle.addTo(map);
35273535
subhorizon_circle_title.addTo(map);
35283536
}
@@ -3615,15 +3623,15 @@ function addPosition(position) {
36153623

36163624
nyanIcon = new L.icon ({
36173625
iconUrl: host_url + markers_url + nyan,
3618-
iconSize: [nyanw,39],
3619-
iconAnchor: [26,20],
3620-
tooltipAnchor: [0,-29],
3626+
iconSize: [nyanw*scale,39*scale],
3627+
iconAnchor: [26*scale,20*scale],
3628+
tooltipAnchor: [0*scale,-29*scale],
36213629
});
36223630

36233631
vehicle_info.marker.setIcon(nyanIcon);
36243632

36253633
vehicle_info.image_src = host_url + markers_url + "hab_nyan.gif";
3626-
vehicle_info.image_src_offset = [-34,-70];
3634+
vehicle_info.image_src_offset = [-34*scale,-70*scale];
36273635

36283636
var k;
36293637
for(k in vehicle_info.polyline) {
@@ -5372,7 +5380,6 @@ function refreshUI() {
53725380
if(follow_vehicle !== null) update_lookangles(follow_vehicle);
53735381
}
53745382

5375-
53765383
function hideHorizonRings(){
53775384
for(var vcallsign in vehicles) {
53785385
if(vehicles[vcallsign].vehicle_type == "balloon"){
@@ -5383,6 +5390,7 @@ function hideHorizonRings(){
53835390
}
53845391
}
53855392
}
5393+
53865394
function showHorizonRings(){
53875395
for(var vcallsign in vehicles) {
53885396
if(vehicles[vcallsign].vehicle_type == "balloon"){
@@ -5394,13 +5402,47 @@ function showHorizonRings(){
53945402
}
53955403
}
53965404

5405+
function updateIconSize(on) {
5406+
if (on) {
5407+
scale = 0.5;
5408+
} else {
5409+
scale = 2;
5410+
}
5411+
for(var vcallsign in vehicles) {
5412+
var icon = vehicles[vcallsign].marker.options.icon;
5413+
icon.options.iconSize = [icon.options.iconSize[0]*scale, icon.options.iconSize[1]*scale];
5414+
icon.options.iconAnchor = [icon.options.iconAnchor[0]*scale, icon.options.iconAnchor[1]*scale];
5415+
icon.options.tooltipAnchor = [icon.options.tooltipAnchor[0]*scale, icon.options.tooltipAnchor[1]*scale];
5416+
vehicles[vcallsign].marker.setIcon(icon);
5417+
if (vehicles[vcallsign].marker_shadow != null) {
5418+
var shadowIcon = vehicles[vcallsign].marker_shadow.options.icon;
5419+
shadowIcon.options.iconSize = [shadowIcon.options.iconSize[0]*scale, shadowIcon.options.iconSize[1]*scale];
5420+
shadowIcon.options.iconAnchor = [shadowIcon.options.iconAnchor[0]*scale, shadowIcon.options.iconAnchor[1]*scale];
5421+
vehicles[vcallsign].marker_shadow.setIcon(shadowIcon);
5422+
}
5423+
if (vehicles[vcallsign].prediction_burst != null) {
5424+
var burstIcon = vehicles[vcallsign].prediction_burst.options.icon;
5425+
burstIcon.options.iconSize = [burstIcon.options.iconSize[0]*scale, burstIcon.options.iconSize[1]*scale];
5426+
burstIcon.options.iconAnchor = [burstIcon.options.iconAnchor[0]*scale, burstIcon.options.iconAnchor[1]*scale];
5427+
vehicles[vcallsign].prediction_burst.setIcon(burstIcon);
5428+
}
5429+
if (vehicles[vcallsign].prediction_target != null) {
5430+
var targetIcon = vehicles[vcallsign].prediction_target.options.icon;
5431+
targetIcon.options.iconSize = [targetIcon.options.iconSize[0]*scale, targetIcon.options.iconSize[1]*scale];
5432+
targetIcon.options.iconAnchor = [targetIcon.options.iconAnchor[0]*scale, targetIcon.options.iconAnchor[1]*scale];
5433+
vehicles[vcallsign].prediction_target.setIcon(targetIcon);
5434+
}
5435+
}
5436+
}
5437+
53975438
function hideTitles(){
53985439
for(var vcallsign in vehicles) {
53995440
if(vehicles[vcallsign].vehicle_type == "balloon" || vehicles[vcallsign].vehicle_type == "car"){
54005441
vehicles[vcallsign].title.unbindTooltip();
54015442
}
54025443
}
54035444
}
5445+
54045446
function showTitles(){
54055447
for(var vcallsign in vehicles) {
54065448
if(vehicles[vcallsign].vehicle_type == "balloon" || vehicles[vcallsign].vehicle_type == "car"){

0 commit comments

Comments
 (0)