Skip to content

Commit a8c612e

Browse files
authored
up (#348)
* Update deps * Drop sponsor Thanks Niviuk for the last 2 years! * remove deprecated fns * minor tweaks
1 parent 652a054 commit a8c612e

File tree

6 files changed

+846
-316
lines changed

6 files changed

+846
-316
lines changed

apps/fxc-front/src/app/components/2d/map-element.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ export class MapElement extends connect(store)(LitElement) {
9999
private lockOnPilot = false;
100100
private lockPanBefore = 0;
101101
private subscriptions: UnsubscribeHandle[] = [];
102-
private readonly adRatio = store.getState().browser.isSmallScreen ? 0.7 : 1;
103102

104103
stateChanged(state: RootState): void {
105104
this.tracks = sel.tracks(state);
@@ -182,16 +181,6 @@ export class MapElement extends connect(store)(LitElement) {
182181
controls.map = this.map;
183182
this.map.controls[google.maps.ControlPosition.TOP_LEFT].push(controls);
184183

185-
if (!store.getState().browser.isFromFfvl) {
186-
const ad = document.createElement('a');
187-
ad.setAttribute('href', 'https://www.niviuk.com/');
188-
ad.setAttribute('target', '_blank');
189-
ad.innerHTML = `<img width="${Math.round(175 * this.adRatio)}" height="${Math.round(
190-
32 * this.adRatio,
191-
)}" src="/static/img/niviuk.svg">`;
192-
this.map.controls[google.maps.ControlPosition.BOTTOM_CENTER].push(ad);
193-
}
194-
195184
this.map.addListener('click', (e: google.maps.MapMouseEvent) => {
196185
const latLng = e.latLng as google.maps.LatLng;
197186
const found = findClosestFix(this.tracks, latLng.lat(), latLng.lng());

apps/fxc-front/src/app/components/3d/airspace3d-element.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class Airspace3dElement extends connect(store)(LitElement) {
7171
this.showTypes,
7272
);
7373
if (html) {
74-
view.popup.open({
74+
view.popup?.open({
7575
location: {
7676
latitude: latLon.lat,
7777
longitude: latLon.lon,

apps/fxc-front/src/app/components/3d/map3d-element.ts

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import './tracking3d-element';
77

88
import Basemap from '@arcgis/core/Basemap';
99
import esriConfig from '@arcgis/core/config';
10+
import { watch } from '@arcgis/core/core/reactiveUtils.js';
1011
import Point from '@arcgis/core/geometry/Point';
1112
import BaseElevationLayer from '@arcgis/core/layers/BaseElevationLayer';
1213
import ElevationLayer from '@arcgis/core/layers/ElevationLayer';
@@ -77,7 +78,6 @@ export class Map3dElement extends connect(store)(LitElement) {
7778
private subscriptions: UnsubscribeHandle[] = [];
7879
private previousLookAt?: LatLonAlt;
7980
private updateCamera = false;
80-
private readonly adRatio = store.getState().browser.isSmallScreen ? 0.7 : 1;
8181

8282
stateChanged(state: RootState): void {
8383
this.tracks = sel.tracks(state);
@@ -99,9 +99,9 @@ export class Map3dElement extends connect(store)(LitElement) {
9999
const dLon = lookAt.lon - this.previousLookAt.lon;
100100
const dAlt = lookAt.alt - this.previousLookAt.alt;
101101
const camera = this.view.camera.clone();
102-
camera.position.latitude += dLat;
103-
camera.position.longitude += dLon;
104-
camera.position.z += dAlt * this.multiplier;
102+
camera.position.latitude = (camera.position.latitude ?? 0) + dLat;
103+
camera.position.longitude = (camera.position.longitude ?? 0) + dLon;
104+
camera.position.z = (camera.position.z ?? 0) + dAlt * this.multiplier;
105105
this.view.camera = camera;
106106
}
107107
}
@@ -200,28 +200,22 @@ export class Map3dElement extends connect(store)(LitElement) {
200200
this.view = view;
201201
this.createLighting();
202202

203-
view.watch('popup.visible', (visible) => {
204-
if (visible == false) {
205-
store.dispatch(setCurrentLiveId(undefined));
206-
}
207-
});
208-
view.popup.viewModel.includeDefaultActions = false;
203+
watch(
204+
() => view.popup?.visible,
205+
(visible) => {
206+
if (visible == false) {
207+
store.dispatch(setCurrentLiveId(undefined));
208+
}
209+
},
210+
);
211+
if (view.popup) {
212+
view.popup.viewModel.includeDefaultActions = false;
213+
}
209214
view.ui.remove('zoom');
210215

211216
const controls = document.createElement('controls3d-element');
212217
view.ui.add(controls, 'top-left');
213218

214-
if (!store.getState().browser.isFromFfvl) {
215-
const ad = document.createElement('a');
216-
ad.setAttribute('href', 'https://www.niviuk.com/');
217-
ad.setAttribute('target', '_blank');
218-
ad.className = 'ad';
219-
ad.innerHTML = `<img width="${Math.round(175 * this.adRatio)}" height="${Math.round(
220-
40 * this.adRatio,
221-
)}" src="/static/img/niviuk.svg">`;
222-
view.ui.add(ad);
223-
}
224-
225219
const layerSwitcher = this.renderRoot.querySelector('#layers') as HTMLSelectElement;
226220
view.ui.add(layerSwitcher, 'top-right');
227221
view.ui.move([layerSwitcher, 'compass', 'navigation-toggle'], 'top-right');
@@ -254,7 +248,10 @@ export class Map3dElement extends connect(store)(LitElement) {
254248
this.center({ ...location, alt: 0 }, zoom);
255249
}
256250

257-
view.watch('center', (point: Point) => this.handleLocation({ lat: point.latitude, lon: point.longitude }));
251+
watch(
252+
() => view.center,
253+
(point: Point) => this.handleLocation({ lat: point.latitude ?? 0, lon: point.longitude ?? 0 }),
254+
);
258255
})
259256
.catch(async (e) => {
260257
store.dispatch(setApiLoading(false));
@@ -288,7 +285,7 @@ export class Map3dElement extends connect(store)(LitElement) {
288285
store.dispatch(setCurrentTrackId(trackId));
289286
}
290287
} else {
291-
this.airspace?.handleClick({ lat: e.mapPoint.latitude, lon: e.mapPoint.longitude }, view);
288+
this.airspace?.handleClick({ lat: e.mapPoint.latitude ?? 0, lon: e.mapPoint.longitude ?? 0 }, view);
292289
}
293290
});
294291
});
@@ -418,12 +415,6 @@ export class Map3dElement extends connect(store)(LitElement) {
418415
#layers {
419416
font: 18px Roboto, arial, sans-serif !important;
420417
}
421-
.ad {
422-
box-shadow: none;
423-
bottom: 10px;
424-
left: 50%;
425-
transform: translate(-50%, 0);
426-
}
427418
</style>
428419
<div id="map3d"></div>
429420
<select id="layers" @change=${(e: any) => this.map?.set('basemap', this.basemaps[e.target.value])}>

apps/fxc-front/src/app/components/3d/tracking3d-element.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,18 +298,18 @@ export class Tracking3DElement extends connect(store)(LitElement) {
298298
point = this.sampler.queryElevation(point) as Point;
299299
}
300300
// The sampler sometimes return incorrect values (i.e. 3.40...e+37).
301-
if (point.z > 20000) {
301+
if ((point.z ?? 0) > 20000) {
302302
point.z = 0;
303303
}
304-
point.z = Math.max(point.z, feature.geometry.coordinates[2] * this.multiplier);
304+
point.z = Math.max(point.z!, feature.geometry.coordinates[2] * this.multiplier);
305305
graphic.set('geometry', point);
306306
graphic.set('attributes', { liveTrackId: pilotId, liveTrackIndex: pointProperties.index });
307307
markers.push(graphic);
308308

309309
if (label) {
310310
const graphic = new Graphic();
311311
point = point.clone();
312-
point.z += MSG_MARKER_HEIGHT;
312+
point.z! += MSG_MARKER_HEIGHT;
313313
graphic.set('geometry', point);
314314
this.txtSymbol.symbolLayers[0].text = label;
315315
this.txtSymbol.symbolLayers[0].material.color = isActive ? '#BF1515' : 'black';
@@ -339,7 +339,7 @@ export class Tracking3DElement extends connect(store)(LitElement) {
339339

340340
const track = liveTrackSelectors.selectById(store.getState(), attr.liveTrackId) as protos.LiveTrack;
341341

342-
view.popup.open({
342+
view.popup?.open({
343343
location: new Point({
344344
latitude: track.lat[index],
345345
longitude: track.lon[index],

0 commit comments

Comments
 (0)