Skip to content

Commit 05a9ecf

Browse files
committed
The marker is back!
1 parent 22457f4 commit 05a9ecf

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

js/plot_config.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,43 @@ function updateLegend(pos) {
6868
}
6969

7070
if(follow_vehicle !== null && vehicles[follow_vehicle].positions.length) {
71+
// adjust index for null data points
72+
var null_count = 0;
73+
74+
if (!map.hasLayer(polyMarker) && polyMarker) {
75+
map.addLayer(polyMarker);
76+
}
77+
78+
if(outside && pij !== undefined) {
79+
if(!polyMarker) {
80+
try {polyMarker = new L.Marker(vehicles[follow_vehicle].prediction_polyline.getLatLngs()[pij]).addTo(map);} catch (e) {};
81+
} else {
82+
try {polyMarker.setLatLng(vehicles[follow_vehicle].prediction_polyline.getLatLngs()[pij]);} catch (e) {};
83+
}
84+
85+
}
86+
else {
87+
var data_ref = vehicles[follow_vehicle].graph_data[0];
88+
89+
if(ij > data_ref.data.length / 2) {
90+
for(i = data_ref.data.length - 1; i > ij; i--) null_count += (data_ref.data[i][1] === null) ? 1 : 0;
91+
null_count = data_ref.nulls - null_count * 2;
92+
} else {
93+
for(i = 0; i < ij; i++) null_count += (data_ref.data[i][1] === null) ? 1 : 0;
94+
null_count *= 2;
95+
}
96+
97+
// update position
98+
ij -= null_count + ((null_count===0||null_count===data_ref.nulls) ? 0 : 1);
99+
if(ij < 0) ij = 0;
100+
101+
if(!polyMarker) {
102+
try {polyMarker = new L.Marker(vehicles[follow_vehicle].positions[ij]).addTo(map);} catch (e) {};
103+
} else {
104+
try {polyMarker.setLatLng(vehicles[follow_vehicle].positions[ij]);} catch (e) {};
105+
}
106+
}
107+
71108
// set timebox
72109
var date = new Date(pos.x1);
73110
$('#timebox').removeClass('present').addClass('past');

js/tracker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,7 +2140,7 @@ function addPosition(position) {
21402140
for(var p in vehicle_info.polyline) {
21412141
map.removeLayer(vehicle_info.polyline[p]);
21422142
}
2143-
} catch (e) {console.log(e)};
2143+
} catch (e) {};
21442144
for (let i = 0; i < potentialobjects.length; i++) {
21452145
if (map.hasLayer(potentialobjects[i])) {
21462146
map.removeLayer(potentialobjects[i]);
@@ -2305,7 +2305,7 @@ function updateGraph(vcallsign, reset_selection) {
23052305
if(reset_selection) {
23062306
if(vcallsign !== null) delete plot_options.xaxis;
23072307

2308-
if(polyMarker) map.remove(polyMarker);
2308+
if(polyMarker) map.removeLayer(polyMarker);
23092309
plot_crosshair_locked = false;
23102310

23112311
$("#timebox").removeClass('past').addClass('present');

0 commit comments

Comments
 (0)