@@ -9,6 +9,7 @@ import 'package:flutter_map/src/map/options/options.dart';
9
9
import 'package:flutter_map/src/misc/bounds.dart' ;
10
10
import 'package:flutter_map/src/misc/point_extensions.dart' ;
11
11
import 'package:latlong2/latlong.dart' ;
12
+ import 'package:vector_math/vector_math_64.dart' ;
12
13
13
14
/// Describes the view of a map. This includes the size/zoom/position/crs as
14
15
/// well as the minimum/maximum zoom. This class is mostly immutable but has
@@ -53,9 +54,6 @@ class MapCamera {
53
54
/// Lazily calculated field
54
55
Point <double >? _pixelOrigin;
55
56
56
- /// Lazily calculated field
57
- double ? _rotationRad;
58
-
59
57
/// This is the [LatLngBounds] corresponding to four corners of this camera.
60
58
/// This takes rotation in to account.
61
59
LatLngBounds get visibleBounds => _bounds ?? = LatLngBounds (
@@ -105,12 +103,10 @@ class MapCamera {
105
103
Bounds <double >? pixelBounds,
106
104
LatLngBounds ? bounds,
107
105
Point <double >? pixelOrigin,
108
- double ? rotationRad,
109
106
}) : _cameraSize = size,
110
107
_pixelBounds = pixelBounds,
111
108
_bounds = bounds,
112
- _pixelOrigin = pixelOrigin,
113
- _rotationRad = rotationRad;
109
+ _pixelOrigin = pixelOrigin;
114
110
115
111
/// Initializes [MapCamera] from the given [options] and with the
116
112
/// [nonRotatedSize] set to [kImpossibleSize] .
@@ -135,7 +131,6 @@ class MapCamera {
135
131
nonRotatedSize: nonRotatedSize,
136
132
minZoom: minZoom,
137
133
maxZoom: maxZoom,
138
- rotationRad: _rotationRad,
139
134
);
140
135
}
141
136
@@ -171,7 +166,6 @@ class MapCamera {
171
166
rotation: rotation,
172
167
nonRotatedSize: nonRotatedSize,
173
168
size: _cameraSize,
174
- rotationRad: _rotationRad,
175
169
);
176
170
}
177
171
@@ -189,7 +183,6 @@ class MapCamera {
189
183
rotation: rotation,
190
184
nonRotatedSize: nonRotatedSize,
191
185
size: _cameraSize,
192
- rotationRad: _rotationRad,
193
186
);
194
187
195
188
/// Calculates the size of a bounding box which surrounds a box of size
@@ -200,7 +193,7 @@ class MapCamera {
200
193
) {
201
194
if (rotation == 0.0 ) return nonRotatedSize;
202
195
203
- final rotationRad = degToRadian ( rotation) ;
196
+ final rotationRad = degrees2Radians * rotation;
204
197
final cosAngle = math.cos (rotationRad).abs ();
205
198
final sinAngle = math.sin (rotationRad).abs ();
206
199
final width = (nonRotatedSize.x * cosAngle) + (nonRotatedSize.y * sinAngle);
@@ -210,9 +203,8 @@ class MapCamera {
210
203
return Point <double >(width, height);
211
204
}
212
205
213
- /// The current rotation value in radians. This is calculated and cached when
214
- /// it is first called.
215
- double get rotationRad => _rotationRad ?? = degToRadian (rotation);
206
+ /// The current rotation value in radians
207
+ double get rotationRad => rotation * degrees2Radians;
216
208
217
209
/// Calculates point value for the given [latLng] using this camera's
218
210
/// [crs] and [zoom] (or the provided [zoom] ).
0 commit comments