这部分是对以前问题的扩展:Android programming, mapview locationoverlay: how to change the default blue location dot, with another image
我一直在努力让设备位置显示在地图上(使用enablemylocation很容易),但我需要替换默认图标(很简单,将其分类),然后旋转它以对应于当前设备的方位 - 从GPS获取,因为它需要成为移动的方向,而不是电话所面对的方向。
我使用'getbearing()'的方式与我成功使用'getlatitude()'和'getaltitude()'相同,但getbearing总是返回0.(为了确保它不是旋转图标是问题,轴承的变量在任何其他事情发生之前以textview打印)
非常奇怪的是,它现在已经在5秒内工作了两次,然后又回到了0 - 所以理论上代码看起来是正确的?
代码如下。
亲切的问候
缺口
主要活动:
package com.nick.kestrel;
import android.content.Context;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.TextView;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
public class KestrelActivity extends MapActivity {
/** Called when the activity is first created. */
static TextView LocationText;
MapView mapView;
@Override
protected boolean isRouteDisplayed() {
return false;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super