Skip to content

Commit

Permalink
fleaflet#736 fix - rebuild layers when size changed with new pixelOrigin
Browse files Browse the repository at this point in the history
  • Loading branch information
maRci002 committed Aug 29, 2020
1 parent 0d88682 commit 25042f0
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/src/map/map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ class MapControllerImpl implements MapController {
}

class MapState {
static const _rad90 = 90.0 * math.pi / 180.0;

MapOptions options;
final ValueChanged<double> onRotationChanged;
final StreamController<Null> _onMoveSink;
Expand Down Expand Up @@ -122,7 +120,7 @@ class MapState {
_originalSize.y != height) {
_originalSize = CustomPoint<double>(width, height);

_updateSizeByOriginalSizeAndRotation();
_updateSizeByOriginalSizeAndRotation(_originalSize != null);
}
}

Expand All @@ -131,17 +129,15 @@ class MapState {

CustomPoint get size => _size;

void _updateSizeByOriginalSizeAndRotation() {
void _updateSizeByOriginalSizeAndRotation([bool callOnMoveSink = false]) {
final originalWidth = _originalSize.x;
final originalHeight = _originalSize.y;

if (_rotation != 0.0) {
final rangle90 = math.sin(_rad90 - _rotationRad).abs();
final sinangle = math.sin(_rotationRad).abs();
// to make sure that the whole screen is filled with the map after rotation
// we enlarge the drawing area over the available screen size
final width = (originalWidth * rangle90) + (originalHeight * sinangle);
final height = (originalHeight * rangle90) + (originalWidth * sinangle);
final cosAngle = math.cos(_rotationRad).abs();
final sinAngle = math.sin(_rotationRad).abs();
final width = (originalWidth * cosAngle) + (originalHeight * sinAngle);
final height = (originalHeight * cosAngle) + (originalWidth * sinAngle);

_size = CustomPoint<double>(width, height);
} else {
Expand All @@ -154,6 +150,10 @@ class MapState {
}

_pixelOrigin = getNewPixelOrigin(_lastCenter);

if (callOnMoveSink) {
_onMoveSink.add(null);
}
}

LatLng get center => getCenter() ?? options.center;
Expand Down

0 comments on commit 25042f0

Please sign in to comment.