Skip to content

Commit

Permalink
Merge branch 'master' into polygon_labels
Browse files Browse the repository at this point in the history
  • Loading branch information
JaffaKetchup authored Oct 28, 2023
2 parents b05dd41 + 394dc27 commit 37fd0ed
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 41 deletions.
56 changes: 30 additions & 26 deletions lib/src/map/widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,38 +139,42 @@ class _FlutterMapStateContainer extends State<FlutterMap>
Widget build(BuildContext context) {
super.build(context);

final widgets = ClipRect(
child: Stack(
children: <Widget>[
Positioned.fill(
child: ColoredBox(color: widget.options.backgroundColor),
),
...widget.children.map(
(child) => TranslucentPointer(
translucent: widget.options.applyPointerTranslucencyToLayers,
child: child,
),
),
...widget.nonRotatedChildren.map(
(child) => TranslucentPointer(
translucent: widget.options.applyPointerTranslucencyToLayers,
child: child,
),
),
],
),
);

return LayoutBuilder(
builder: (context, constraints) {
_updateAndEmitSizeIfConstraintsChanged(constraints);

return FlutterMapInteractiveViewer(
controller: _flutterMapInternalController,
builder: (context, options, camera) => FlutterMapInheritedModel(
controller: _mapController,
options: options,
camera: camera,
child: ClipRect(
child: Stack(
children: [
Positioned.fill(
child: ColoredBox(color: options.backgroundColor),
),
...widget.children.map(
(child) => TranslucentPointer(
translucent: options.applyPointerTranslucencyToLayers,
child: child,
),
),
...widget.nonRotatedChildren.map(
(child) => TranslucentPointer(
translucent: options.applyPointerTranslucencyToLayers,
child: child,
),
),
],
),
),
),
builder: (context, options, camera) {
return FlutterMapInheritedModel(
controller: _mapController,
options: options,
camera: camera,
child: widgets,
);
},
);
},
);
Expand Down
25 changes: 10 additions & 15 deletions lib/src/misc/bounds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class Bounds<T extends num> {
final Point<T> max;

factory Bounds(Point<T> a, Point<T> b) {
final bounds1 = Bounds._(a, b);
final bounds2 = bounds1.extend(a);
return bounds2.extend(b);
final (minx, maxx) = a.x > b.x ? (b.x, a.x) : (a.x, b.x);
final (miny, maxy) = a.y > b.y ? (b.y, a.y) : (a.y, b.y);
return Bounds._(Point<T>(minx, miny), Point<T>(maxx, maxy));
}

const Bounds._(this.min, this.max);
Expand All @@ -38,14 +38,8 @@ class Bounds<T extends num> {
/// point.
Bounds<T> extend(Point<T> point) {
return Bounds._(
Point(
math.min(point.x, min.x),
math.min(point.y, min.y),
),
Point(
math.max(point.x, max.x),
math.max(point.y, max.y),
),
Point(math.min(point.x, min.x), math.min(point.y, min.y)),
Point(math.max(point.x, max.x), math.max(point.y, max.y)),
);
}

Expand Down Expand Up @@ -73,9 +67,10 @@ class Bounds<T extends num> {
}

bool contains(Point<T> point) {
final min = point;
final max = point;
return containsBounds(Bounds(min, max));
return (point.x >= min.x) &&
(point.x <= max.x) &&
(point.y >= min.y) &&
(point.y <= max.y);
}

bool containsBounds(Bounds<T> b) {
Expand All @@ -102,7 +97,7 @@ class Bounds<T extends num> {
final bottomY = math.min(max.y, b.max.y);

if (leftX <= rightX && topY <= bottomY) {
return Bounds(Point(leftX, topY), Point(rightX, bottomY));
return Bounds._(Point(leftX, topY), Point(rightX, bottomY));
}

return null;
Expand Down

0 comments on commit 37fd0ed

Please sign in to comment.