雷达上的比例坐标

Scale coordinates on radar

我目前正在为 android 开发雷达。 (遵循本教程:http://www.androidph.com/2009/02/app-10-beer-radar.html

我从服务器获取我当前位置周围 5KM 范围内的所有用户,然后我在我的自定义视图中绘制如下:

float xU = (float)(userLocation.getLongitude() + getWidth() / 2 - currentLong);
float yU = (float)(getHeight() / 2 - userLocation.getLatitude() + currentLat);
canvas.drawBitmap(bmpUser,xU,yU,radarPaint);

现在我的问题是,我需要缩放我在雷达上绘制的点/坐标,因为 5KM 以下距离内的所有用户都将被绘制为距中心仅 2-3 个像素。我将如何做到这一点?

这是一种方法。您需要做的就是将 "scale" 变量的值设置为所需的值;

float scale = 3.0f; //set this to any number to change the drawing scale

float xU = (float)(getWidth() / 2 + (userLocation.getLongitude() - currentLong) * scale);
float yU = (float)(getHeight() / 2 - (userLocation.getLatitude() - currentLat) * scale);
canvas.drawBitmap(bmpUser,xU,yU,radarPaint);