gpt4 book ai didi

android - 从 osmdroid MapView 获取 MyLocationOverlay

转载 作者:行者123 更新时间:2023-11-29 18:08:37 26 4
gpt4 key购买 nike

我正在创建一个应用程序,您可以在其中使用 MyLocationOverlay 打开和关闭 FollowLocation。

我的问题是,当我之前已经设置了 MyLocationOverlay 并想要打开 FollowLocation 时,但我似乎无法在 MapView 的 OverlayManager 中找到/获取 MyLocationOverlay 对象。 OverlayManager 似乎只返回一个 Overlay 对象,而不是 MyLocationOverlay 对象。

这就是我添加 MyLocationOverlay 的方式:

main_mapView = (MapView) findViewById(R.id.main_mapView);   
MyLocationOverlay mMyLocationOverlay = new MyLocationOverlay(mContext, main_mapView);
mMyLocationOverlay.enableMyLocation();
mMyLocationOverlay.enableCompass();
mMyLocationOverlay.main_mapView.getOverlays().add(mMyLocationOverlay);
main_mapView.invalidate();

稍后我想找到 MyLocationOverlay 做这样的事情,但如前所述,它返回一个 Overlay 对象。

MyLocationOverlay mMyLocationOverlay = main_mapView.getOverlayManager().get(i);
mMyLocationOverlay.enableFollowLocation()

有人吗?

最佳答案

只需保留对您最初新建的 MyLocationOverlay 的引用...无需从覆盖管理器取回它。

关于android - 从 osmdroid MapView 获取 MyLocationOverlay,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12030422/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com