使用indooratlas在android中发布

时间:2015-07-29 05:01:56

标签: android canvas

我正在尝试画一个圈子以获得定位的东西,但我没有运气,我在这里使用Android画布是我的方法 -

    public void onServiceUpdate(ServiceState state) {

    mSharedBuilder.setLength(0);
    mSharedBuilder.append("Location: ")
            .append("\n\troundtrip : ").append(state.getRoundtrip()).append("ms")
            .append("\n\tlat : ").append(state.getGeoPoint().getLatitude())
            .append("\n\tlon : ").append(state.getGeoPoint().getLongitude())
            .append("\n\tX [meter] : ").append(state.getMetricPoint().getX())
            .append("\n\tY [meter] : ").append(state.getMetricPoint().getY())
            .append("\n\tI [pixel] : ").append(state.getImagePoint().getI())
            .append("\n\tJ [pixel] : ").append(state.getImagePoint().getJ())
            .append("\n\theading : ").append(state.getHeadingDegrees())
            .append("\n\tuncertainty: ").append(state.getUncertainty());

    log(mSharedBuilder.toString());
    double x1 = state.getMetricPoint().getX();
    double y1 = state.getMetricPoint().getY();
    float x = (float) x1;
    float y = (float) y1;


    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setAntiAlias(true);
    paint.setColor(Color.BLUE);
    Bitmap image = null;
    Bitmap workingBitmap = Bitmap.createBitmap(image);
    Bitmap mutableBitmap = workingBitmap.copy(Bitmap.Config.ARGB_8888, true);

    Canvas canvas = new Canvas(mutableBitmap);
    canvas.drawCircle(x, y, 10, paint);

    imageView.setAdjustViewBounds(true);
    imageView.setImageBitmap(image);

}

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

这是我的完整代码。它也可能适合你。只需在声明中编辑一些必要的内容。

public void onServiceUpdate(ServiceState state) {
    log("onServiceUpdate");
    mSharedBuilder.setLength(0);
    mSharedBuilder.append("Location: ")
            .append("\n\tPing : ").append(state.getRoundtrip()).append("ms")
            .append("\n\tLatitude : ").append(state.getGeoPoint().getLatitude())
            .append("\n\tLongitude : ").append(state.getGeoPoint().getLongitude())
            .append("\n\tX [meter] : ").append(state.getMetricPoint().getX())
            .append("\n\tY [meter] : ").append(state.getMetricPoint().getY())
            .append("\n\tI [pixel] : ").append(state.getImagePoint().getI())
            .append("\n\tJ [pixel] : ").append(state.getImagePoint().getJ())
            .append("\n\tHeading : ").append(state.getHeadingDegrees())
            .append("\n\tUncertainty: ").append(state.getUncertainty());

    log(mSharedBuilder.toString());
        final int i, j;
        i = state.getImagePoint().getI();
        j = state.getImagePoint().getJ();
        ImageView imageView = (ImageView) findViewById(R.id.imageView);
        imageView.buildDrawingCache();
        Bitmap bitmap = imageView.getDrawingCache();
        final ImageView imageFloor = (ImageView) findViewById(R.id.imageView);
        final Bitmap bitmapCircle = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());
        Canvas canvas = new Canvas(bitmapCircle);
        Paint paint = new Paint();
        paint.setAntiAlias(true);
        paint.setColor(Color.BLUE);
        paint.setStrokeWidth(10);
        canvas.drawBitmap(bitmap, new Matrix(), null);
        canvas.drawCircle(i, j, 10, paint);
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                imageFloor.setImageBitmap(bitmapCircle);
            }
        });