@@ -4,6 +4,8 @@ class MapApplet {
4
4
5
5
#map;
6
6
#droneVectors;
7
+ #takeoffLocationVectors = [ ] ;
8
+ #landingLocationVectors = [ ] ;
7
9
8
10
#preferredZoomLevel = 18 ;
9
11
@@ -87,8 +89,11 @@ class MapApplet {
87
89
let droneId = Object . keys ( drones ) [ i ] ;
88
90
let drone = drones [ droneId ] ;
89
91
92
+ this . #updateVectorPointCoordinates( this . #landingLocationVectors[ i ] , drone . getLandingGpsLat ( ) , drone . getLandingGpsLon ( ) ) ;
93
+ this . #updateVectorPointCoordinates( this . #takeoffLocationVectors[ i ] , drone . getTakeoffGpsLat ( ) , drone . getTakeoffGpsLon ( ) ) ;
94
+
90
95
this . #updateVectorPointCoordinates( this . #droneVectors[ i ] , drone . getGpsLat ( ) , drone . getGpsLon ( ) ) ;
91
- this . #updateVectorPointRotation( this . #droneVectors[ i ] , drone . getYaw ( ) ) ;
96
+ this . #updateVectorPointRotation( this . #droneVectors[ i ] , drone . getYaw ( ) , drone . getDroneImageSource ( ) , drone . getDroneImageScale ( ) ) ;
92
97
}
93
98
} else {
94
99
// Different drones
@@ -99,7 +104,11 @@ class MapApplet {
99
104
for ( drone_id in drones ) {
100
105
const drone = drones [ drone_id ] ;
101
106
102
- this . #droneVectors. push ( this . #createAndAddVectorPoint( this . #map, drone . getGpsLat ( ) , drone . getGpsLon ( ) ) ) ;
107
+ this . #landingLocationVectors. push ( this . #createAndAddVectorPoint( this . #map, drone . getLandingGpsLat ( ) , drone . getLandingGpsLon ( ) , drone . getLandingLocationImageSource ( ) , drone . getLandingLocationImageScale ( ) ) ) ;
108
+ this . #takeoffLocationVectors. push ( this . #createAndAddVectorPoint( this . #map, drone . getTakeoffGpsLat ( ) , drone . getTakeoffGpsLon ( ) , drone . getTakeoffLocationImageSource ( ) , drone . getTakeoffLocationImageScale ( ) ) ) ;
109
+
110
+ this . #droneVectors. push ( this . #createAndAddVectorPoint( this . #map, drone . getGpsLat ( ) , drone . getGpsLon ( ) , this . #drones[ drone_id ] . getDroneImageSource ( ) ) ) ;
111
+ // TODO: rotate drone
103
112
}
104
113
}
105
114
@@ -108,7 +117,7 @@ class MapApplet {
108
117
}
109
118
110
119
111
- #createVectorPoint( lat , lon ) {
120
+ #createVectorPoint( lat , lon , imageSource , imageScale ) {
112
121
return new ol . layer . Vector ( {
113
122
source : new ol . source . Vector ( {
114
123
features : [
@@ -119,16 +128,15 @@ class MapApplet {
119
128
} ) ,
120
129
style : new ol . style . Style ( {
121
130
image : new ol . style . Icon ( {
122
- src : './img/drone.svg' ,
123
- rotation : 30 ,
124
- scale : 1.5
131
+ src : imageSource ,
132
+ scale : imageScale
125
133
} ) ,
126
134
} )
127
135
} ) ;
128
136
}
129
137
130
- #createAndAddVectorPoint( map , lat , lon ) {
131
- let vector = this . #createVectorPoint( lat , lon ) ;
138
+ #createAndAddVectorPoint( map , lat , lon , imageSource , imageScale ) {
139
+ let vector = this . #createVectorPoint( lat , lon , imageSource , imageScale ) ;
132
140
this . #map. addLayer ( vector ) ;
133
141
return vector ;
134
142
}
@@ -147,12 +155,12 @@ class MapApplet {
147
155
}
148
156
149
157
150
- #updateVectorPointRotation( vector , rotation ) {
158
+ #updateVectorPointRotation( vector , rotation , imageSource , imageScale ) {
151
159
let newStyle = new ol . style . Style ( {
152
160
image : new ol . style . Icon ( {
153
- src : './img/drone.svg' ,
154
- rotation : rotation * ( 3.1415 / 180 ) ,
155
- scale : 1.5
161
+ src : imageSource ,
162
+ scale : imageScale ,
163
+ rotation : rotation * ( 3.1415 / 180 )
156
164
} ) ,
157
165
} )
158
166
0 commit comments