[英]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- 我正在尝试画一个圆圈来放置东西,但是我没有运气,我在这里使用android canvas-
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);
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.