createLocationMarkerIcon3 function
Implementation
Future<BitmapDescriptor> createLocationMarkerIcon3(double size, Color color) async {
final PictureRecorder pictureRecorder = PictureRecorder();
final Canvas canvas = Canvas(pictureRecorder);
final double centerX = size / 2;
final double centerY = size / 2;
final double radius = size / 2;
final double distanceFromCenter = size * 0.3;
const double markerWidth = 5.0;
final double markerLength = size * 0.4;
final Paint circlePaint = Paint()..color = color;
canvas.drawCircle(Offset(centerX, centerY), radius, circlePaint);
const double angle1 = math.pi / 4; // 45 derece
const double angle2 = 3 * math.pi / 4; // 135 derece
final double startX1 = centerX + distanceFromCenter * math.cos(angle1);
final double startY1 = centerY + distanceFromCenter * math.sin(angle1);
final double endX1 = startX1 + markerLength * math.cos(angle1);
final double endY1 = startY1 + markerLength * math.sin(angle1);
final double startX2 = centerX + distanceFromCenter * math.cos(angle2);
final double startY2 = centerY + distanceFromCenter * math.sin(angle2);
final double endX2 = startX2 + markerLength * math.cos(angle2);
final double endY2 = startY2 + markerLength * math.sin(angle2);
final Paint markerPaint = Paint()
..color = color
..strokeWidth = markerWidth
..strokeCap = StrokeCap.round;
canvas.drawLine(Offset(startX1, startY1), Offset(endX1, endY1), markerPaint);
canvas.drawLine(Offset(startX2, startY2), Offset(endX2, endY2), markerPaint);
final ui.Picture picture = pictureRecorder.endRecording();
final ui.Image image = await picture.toImage(size.toInt(), size.toInt());
final ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png);
final Uint8List data = byteData!.buffer.asUint8List();
return BitmapDescriptor.fromBytes(data);
}