@@ -7,6 +7,7 @@ import './tracking3d-element';
7
7
8
8
import Basemap from '@arcgis/core/Basemap' ;
9
9
import esriConfig from '@arcgis/core/config' ;
10
+ import { watch } from '@arcgis/core/core/reactiveUtils.js' ;
10
11
import Point from '@arcgis/core/geometry/Point' ;
11
12
import BaseElevationLayer from '@arcgis/core/layers/BaseElevationLayer' ;
12
13
import ElevationLayer from '@arcgis/core/layers/ElevationLayer' ;
@@ -77,7 +78,6 @@ export class Map3dElement extends connect(store)(LitElement) {
77
78
private subscriptions :UnsubscribeHandle [ ] = [ ] ;
78
79
private previousLookAt ?:LatLonAlt ;
79
80
private updateCamera = false ;
80
- private readonly adRatio = store . getState ( ) . browser . isSmallScreen ?0.7 :1 ;
81
81
82
82
stateChanged ( state :RootState ) :void {
83
83
this . tracks = sel . tracks ( state ) ;
@@ -99,9 +99,9 @@ export class Map3dElement extends connect(store)(LitElement) {
99
99
const dLon = lookAt . lon - this . previousLookAt . lon ;
100
100
const dAlt = lookAt . alt - this . previousLookAt . alt ;
101
101
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 ;
105
105
this . view . camera = camera ;
106
106
}
107
107
}
@@ -200,28 +200,22 @@ export class Map3dElement extends connect(store)(LitElement) {
200
200
this . view = view ;
201
201
this . createLighting ( ) ;
202
202
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
+ }
209
214
view . ui . remove ( 'zoom' ) ;
210
215
211
216
const controls = document . createElement ( 'controls3d-element' ) ;
212
217
view . ui . add ( controls , 'top-left' ) ;
213
218
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
-
225
219
const layerSwitcher = this . renderRoot . querySelector ( '#layers' ) as HTMLSelectElement ;
226
220
view . ui . add ( layerSwitcher , 'top-right' ) ;
227
221
view . ui . move ( [ layerSwitcher , 'compass' , 'navigation-toggle' ] , 'top-right' ) ;
@@ -254,7 +248,10 @@ export class Map3dElement extends connect(store)(LitElement) {
254
248
this . center ( { ...location , alt :0 } , zoom ) ;
255
249
}
256
250
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
+ ) ;
258
255
} )
259
256
. catch ( async ( e ) => {
260
257
store . dispatch ( setApiLoading ( false ) ) ;
@@ -288,7 +285,7 @@ export class Map3dElement extends connect(store)(LitElement) {
288
285
store . dispatch ( setCurrentTrackId ( trackId ) ) ;
289
286
}
290
287
} 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 ) ;
292
289
}
293
290
} ) ;
294
291
} ) ;
@@ -418,12 +415,6 @@ export class Map3dElement extends connect(store)(LitElement) {
418
415
# layers {
419
416
font : 18px Roboto, arial, sans-serif!important ;
420
417
}
421
- .ad {
422
- box-shadow : none;
423
- bottom : 10px ;
424
- left : 50% ;
425
- transform : translate (-50% , 0 );
426
- }
427
418
</ style >
428
419
< div id ="map3d "> </ div >
429
420
< select id ="layers "@change =${ ( e :any ) => this . map ?. set ( 'basemap' , this . basemaps [ e . target . value ] ) } >