我在我的地图上显示了一个 GroundOverlay,它的图像是用画布制作的,我在画布上画了一个弧线,但我遇到了一些问题:首先,应用程序在一段时间后崩溃(它给了我一个 java .lang.OutOfMemoryError),并且它没有显示覆盖。我尝试在叠加层的图片中放置白色背景并显示它,所以我猜问题来自弧线,但我不知道我做错了什么。有人知道吗?
Projection projection = map.getProjection();
Point point1 = projection.toScreenLocation(latlng1);
Point point2 = projection.toScreenLocation(latlng2);
float startAngle = (float) (Math.atan2(point1.y - point2.y,
point1.x - point2.x));
float sweepAngle = (float) (GenericNdData.getLateralTrajectory(
T_FplnType.ACTIVE.getId()).getSegment(i).getAngle());
float radius = FloatMath.sqrt((float) (Math.pow(
(point1.x - point2.x), 2) + Math.pow(
(point1.y - point2.y), 2)));
RectF rectangle = new RectF(point2.x - radius, point2.y
- radius, point2.x + radius, point2.y + radius);
Paint paint = new Paint();
paint.setARGB(250, 0, 255, 0);
paint.setAntiAlias(true);
paint.setSubpixelText(true);
paint.setFakeBoldText(true);
paint.setStrokeWidth(4f * Configuration.General.getScreenFactor());
paint.setStyle(Paint.Style.STROKE);
Bitmap arc = Bitmap.createBitmap(500, 500, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(arc);
canvas.drawColor(0xFFFFFFFF);
canvas.drawArc(rectangle,
(float) (Math.toDegrees(startAngle)),
(float) (Math.toDegrees(sweepAngle)), false, paint);
GroundOverlay groundArc = map.addGroundOverlay(new GroundOverlayOptions()
.image(BitmapDescriptorFactory.fromBitmap(arc))
.position(latlng2, 10000));
提前致谢。