简体   繁体   中英

Positing in android using indooratlas

I am trying to draw a circle for getting positing stuff work but I don't have any luck, I am using android canvas here is my method-

    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);

}

Thanks for the help

Here is my complete code. It might works for you too. Just edit a little necessary in your declaration.

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);
            }
        });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM