Skip to content

Commit

Permalink
Use point extension's toOffset()
Browse files Browse the repository at this point in the history
  • Loading branch information
rorystephenson committed Jul 18, 2023
1 parent 6d517a6 commit 3471c44
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
5 changes: 1 addition & 4 deletions lib/src/layer/label.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ class Label {
final labelPosition = polylabel([
points.map((p) => math.Point(p.dx, p.dy)).toList(),
]);
return Offset(
labelPosition.point.x.toDouble(),
labelPosition.point.y.toDouble(),
);
return labelPosition.point.toOffset();
}
}
8 changes: 3 additions & 5 deletions lib/src/map/camera/camera.dart
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,8 @@ class MapCamera {
crs.getProjectedBounds(zoom ?? this.zoom);

/// Calculates the [Offset] from the [pos] to this camera's [pixelOrigin].
Offset getOffsetFromOrigin(LatLng pos) {
final delta = project(pos).subtract(pixelOrigin);
return Offset(delta.x, delta.y);
}
Offset getOffsetFromOrigin(LatLng pos) =>
project(pos).subtract(pixelOrigin).toOffset();

/// Calculates the pixel origin of this [MapCamera] at the given
/// [center]/[zoom].
Expand Down Expand Up @@ -325,7 +323,7 @@ class MapCamera {
..rotateZ(rotationRad * counterRotationFactor)
..translate(-mapCenter.x, -mapCenter.y);

final tp = MatrixUtils.transformPoint(m, Offset(point.x, point.y));
final tp = MatrixUtils.transformPoint(m, point.toOffset());

return Point(tp.dx, tp.dy);
}
Expand Down

0 comments on commit 3471c44

Please sign in to comment.