获取当前位置IndoorAtlas SDK时ImageView的绘制圆 [英] Draw Circle in ImageView when getting current location IndoorAtlas SDK

查看:176
本文介绍了获取当前位置IndoorAtlas SDK时ImageView的绘制圆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得当前位置,并绘制蓝点上面的图片。蓝点是移动当前位置改变时。

I want to get current location and draw blue dot like picture above. The blue dot is moving when the current location change.

下面是我的code:

public void onServiceUpdate(ServiceState state) {
    mSharedBuilder.setLength(0);
    mSharedBuilder.append("Location: ")
            .append(state.getRoundtrip()).append("ms")
            .append(state.getGeoPoint().getLatitude())
            .append(state.getGeoPoint().getLongitude())
            .append(state.getMetricPoint().getX())
            .append(state.getMetricPoint().getY())
            .append(state.getImagePoint().getI())
            .append(state.getImagePoint().getJ())
            .append(state.getHeadingDegrees())
            .append(state.getUncertainty());
    double x1 = state.getMetricPoint().getX();
    double y1 = state.getMetricPoint().getY();
    float x = (float) x1;
    float y = (float) y1;
    Paint paint = null;
    canvas.drawCircle(x,y,1,paint);
}

你能帮助我吗?在资源文件夹中的图片了。

Could you help me ? The pictures already in resource folder.

推荐答案

首先,在这种情况下,更容易,如果你使用的坐标从ServiceState#getImagePoint() - 这些(I和J),在有你的位置坐标原始平面图。即如果你原来的映射和放大器;上传平面图有尺寸800×600,服务可能会返回我的位置:400,J:300,表明你现在在你的映射区域的中心。

First, in this case it is easier if you use coordinates from ServiceState#getImagePoint() - these (I & J) are coordinates of your location in the original floor plan. I.e. if your original mapped & uploaded floor plan had dimensions 800x600, service might return position I:400,J:300 indicating that you are now in the center of your mapped area.

您却无法得出这样一个循环:canvas.drawCircle(400,300,半径,油漆) - 因为这取决于你的形象是如何当前显示(例如缩放),你可能会被绘制​​到不正确的位置。

You cannot however draw a circle like this: canvas.drawCircle(400, 300, radius, paint) - because depending on how your image is currently displayed (e.g. scaled) you might be drawing into incorrect location.

您需要考虑到您的影像出现在屏幕上,它是当前尺寸,即缩放比率是什么。例如。如果你有大小1920×1080的显示尺寸800×600的楼层平面图绘制图像居中,而没有任何缩放成占据整个屏幕房地产的ImageView的(假设纵向这里满1920×1080),那么你就需要绘制当前坐标(400300)插入画布在x:((1080-800)/ 2)+400,Y:((1920-600 / 2)+300)= 540960

You need to take into account where your image is on the screen and what are it's current dimensions, i.e. scaling ratio. E.g. if you have a display of size 1920x1080 and your floor plan image of size 800x600 is drawn centered and without any scaling into an ImageView that occupies the entire screen real estate (assume full 1920x1080 in portrait here), then you would need to draw your current coordinate (400,300) into canvas at x: ((1080-800)/2)+400, y: ((1920-600/2)+300) = 540,960.

要与蓝点(半透明大圆圈)绘制的精度,使用的不确定性来计算圆半径。

To draw accuracy with the blue dot (the semi-transparent larger circle), use uncertainty to calculate circle radius.

这篇关于获取当前位置IndoorAtlas SDK时ImageView的绘制圆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆