Skip to content

Commit c1545dc

Browse files
Use point extension's toOffset()
1 parent 9cd578b commit c1545dc

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

lib/src/layer/label.dart

+1-4
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ class Label {
6969
final labelPosition = polylabel([
7070
points.map((p) => math.Point(p.dx, p.dy)).toList(),
7171
]);
72-
return Offset(
73-
labelPosition.point.x.toDouble(),
74-
labelPosition.point.y.toDouble(),
75-
);
72+
return labelPosition.point.toOffset();
7673
}
7774
}

lib/src/map/camera/camera.dart

+3-5
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,8 @@ class MapCamera {
249249
crs.getProjectedBounds(zoom ?? this.zoom);
250250

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

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

328-
final tp = MatrixUtils.transformPoint(m, Offset(point.x, point.y));
326+
final tp = MatrixUtils.transformPoint(m, point.toOffset());
329327

330328
return Point(tp.dx, tp.dy);
331329
}

0 commit comments

Comments
 (0)