Skip to content

Commit

Permalink
同じ場所にマーカーがある場合、ずらして表示する
Browse files Browse the repository at this point in the history
  • Loading branch information
numa08 committed Jan 25, 2024
1 parent 5518d60 commit 75d07e0
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions app/radio_qth_map/lib/widget/operation_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,20 @@ class OperationMapState extends State<OperationMap>
_operationMarkers =
operations.fold(<Marker>[], (markerList, operation) {
final point = operation.location.latLng;
// 同じ場所にマーカーがある場合、少しずらして表示する
final LatLng adjustedPoint;
if (markerList.any((element) => element.point == point)) {
adjustedPoint = LatLng(
point.latitude + 0.001,
point.longitude + 0.001,
);
} else {
adjustedPoint = point;
// 同じ場所にマーカーがあるか再帰的にチェックし、重複を防ぐ
LatLng distinctMarker(LatLng point) {
if (markerList.any((element) => element.point == point)) {
final adjustedPoint = LatLng(
point.latitude + 0.001,
point.longitude + 0.001,
);
return distinctMarker(adjustedPoint);
} else {
return point;
}
}

final LatLng adjustedPoint = distinctMarker(point);
final marker = Marker(
point: adjustedPoint,
child: GestureDetector(
Expand Down

0 comments on commit 75d07e0

Please sign in to comment.