【发布时间】:2011-12-17 14:34:32
【问题描述】:
我正在尝试使用指南针之类的东西,将经度/纬度值传递给它以使其指向特定位置,我的代码可以在移动手机(使用 GPS)以确定位置时绘制箭头。
我想用图片代替绘图
public void draw(Canvas canvas) {
double angle = calculateAngle(currentLongitude, currentLatitude, targetLongitude, targetLatitude);
//Correction;
angle-=90;
//Correction for azimuth
angle-=azimuth;
if((getContext() instanceof Activity) && ((Activity)getContext()).getWindowManager().getDefaultDisplay().getOrientation()==Configuration.ORIENTATION_PORTRAIT)angle-=90;
while(angle<0)angle=angle+360;
Rect rect = canvas.getClipBounds();
int height = rect.bottom-rect.top;
int width = rect.right-rect.left;
int left = rect.left;
int top = rect.top;
}
【问题讨论】:
-
要实现移动地图吗?
-
这段代码似乎遗漏了问题的一部分,因为它没有绘制任何东西并且它包含其他问题,比如 if-case 适合的 while 循环
标签: android gps drawing rotation compass-geolocation