问题描述
我正在为我的beta版导航应用程序集成Android Auto Car Library。我已经成功实现了导航模板,但是由于无法使用画布绘制自己的地图,因此只能集成第三方地图sdk(例如此处的地图,地图框等),
if (mSurface == null || !mSurface.isValid()) {
// Surface is not available,or has been destroyed,skip this frame.
return;
}
Canvas canvas = mSurface.lockCanvas(null);
// Clear the background.
canvas.drawColor(mCarContext.isDarkMode() ? Color.DKGRAY : Color.LTGRAY);
final int horizontalTextMargin = 10;
final int verticalTextMarginFromTop = 20;
final int verticalTextMarginFromBottom = 10;
// Draw a rectangle showing the inset.
Rect visibleArea = mVisibleArea;
if (visibleArea != null) {
if (visibleArea.isEmpty()) {
// No inset set. The entire area is considered safe to draw.
visibleArea.set(0,canvas.getWidth() - 1,canvas.getHeight() - 1);
}
canvas.drawRect(visibleArea,mLeftInsetPaint);
canvas.drawLine(
visibleArea.left,visibleArea.top,visibleArea.right,visibleArea.bottom,mLeftInsetPaint);
canvas.drawLine(
visibleArea.right,visibleArea.left,mLeftInsetPaint);
canvas.drawText(
"(" + visibleArea.left + "," + visibleArea.top + ")",visibleArea.left + horizontalTextMargin,visibleArea.top + verticalTextMarginFromTop,mLeftInsetPaint);
canvas.drawText(
"(" + visibleArea.right + "," + visibleArea.bottom + ")",visibleArea.right - horizontalTextMargin,visibleArea.bottom - verticalTextMarginFromBottom,mRightInsetPaint);
} else {
Log.d(TAG,"Visible area not available.");
}
if (mStableArea != null) {
// Draw a cross-hairs at the stable center.
final int lengthPx = 15;
int centerX = mStableArea.centerX();
int centerY = mStableArea.centerY();
canvas.drawLine(centerX - lengthPx,centerY,centerX + lengthPx,mCenterPaint);
canvas.drawLine(centerX,centerY - lengthPx,centerX,centerY + lengthPx,mCenterPaint);
canvas.drawText(
"(" + centerX + "," + centerY + ")",centerX + horizontalTextMargin,mCenterPaint);
} else {
Log.d(TAG,"Stable area not available.");
}
if (mShowMarkers) {
// Show a set number of markers centered around the midpoint of the stable area. If no
// stable area,then use visible area or canvas dimensions. If an active marker is set draw
// a line from the center to that marker.
Rect markerArea =
mStableArea != null
? mStableArea
: (mVisibleArea != null
? mVisibleArea
: new Rect(0,canvas.getHeight()));
int centerX = markerArea.centerX();
int centerY = markerArea.centerY();
double radius = Math.min(centerX / 2,centerY / 2);
double circleAngle = 2.0d * Math.PI;
double markerpiece = circleAngle / mNumMarkers;
for (int i = 0; i < mNumMarkers; i++) {
int markerX = centerX + (int) (radius * Math.cos(markerpiece * i));
int markerY = centerY + (int) (radius * Math.sin(markerpiece * i));
canvas.drawCircle(markerX,markerY,5,mMarkerPaint);
if (i == mActiveMarker) {
canvas.drawLine(centerX,markerX,mMarkerPaint);
}
}
}
mSurface.unlockCanvasAndPost(canvas);
但就我而言,我只想使用第三方SDK。我只是想知道如何做到或是否有可能做到。将不胜感激。谢谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)