【问题标题】:How to make map rotate instead of my current location marker osmdroid如何使地图旋转而不是我当前的位置标记osmdroid
【发布时间】:2016-03-05 22:46:34
【问题描述】:

我正在编写一个使用 osmdroid 的 android 应用程序。现在地图显示,我当前的位置标记(三角形)在地图顶部旋转。而不是这个,我希望 MAP 旋转并将当前位置三角形标记锁定在一个位置,就像典型的汽车 GPS 一样。这是我当前的代码。

public class MainActivity extends Activity {

protected static final String PROVIDER_NAME = LocationManager.GPS_PROVIDER;
public static final GeoPoint SCHOOL = new GeoPoint(33.989820, -81.029123);

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    MapView mapView = (MapView) findViewById(R.id.mapview);
    mapView.setClickable(true);
    mapView.setBuiltInZoomControls(true);
    mapView.setMultiTouchControls(true);
    mapView.setUseDataConnection(true);
    //mapView.setMapOrientation(0);
    mapView.setTileSource(TileSourceFactory.MAPQUESTOSM);

    MyLocationNewOverlay myLocationOverlay = new MyLocationNewOverlay(getApplicationContext(), mapView);
    myLocationOverlay.enableMyLocation();
    myLocationOverlay.enableFollowLocation();

    mapView.getOverlays().add(myLocationOverlay);
    IMapController mapViewController = mapView.getController();
    mapViewController.setZoom(16);
   }

}

关于需要修复/添加什么的任何想法?

【问题讨论】:

    标签: android gps osmdroid


    【解决方案1】:

    您想要的行为在 OSMNavigator MapActivity 中实现,使用:DirectedLocationOverlay 和 LocationListener。 看一看。

    【讨论】:

    • 感谢您的参考。您能否指出对我有用的部分?我浏览了代码,但不确定到底什么对我有帮助,因为它太长了
    • 相关对象有:myLocationOverlay、mLocationManager。该活动扩展了 LocationListener。而且大部分相关代码都在onLocationChanged中。
    • 有没有办法以简单的方式实现我的要求?可能是示例代码
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-13
    • 1970-01-01
    相关资源
    最近更新 更多