mylocationoverlay 第一次找到位置时消失
我正在尝试设置 mylocationoverlay。不幸的是,它的行为很奇怪。它工作正常,但直到我离开 MapActivity 并返回到我的应用程序中后它才会出现。最初,地图会出现,当它获得良好位置时,会出现一个蓝色圆圈。然而,圆圈并没有分解成一个点,而是消失了。
我的代码如下所示:
onResume() {
myLocation = new MyLocationOverlay(getActivity(), mp);
myLocation.enableMyLocation();
myLocation.runOnFirstFix(new Runnable(){
public void run() {
map.getOverlays().clear();
map.getOverlays().add(myLocation);
map.postInvalidate();
}
}
}
onPause() {
myLocation.disableMyLocation();
layout.removeView(map);
map = null;
}
有谁对这里可能发生的事情有任何想法吗?由于这几乎是所有在线示例的逐字样,我可能会补充一点,我正在运行 2.3.4 的 motorolla atrix 上测试它。
I am trying to setup a mylocationoverlay. Unfortunately, it is acting quite strangely. It works fine, except it does not appear until after I leave the MapActivity and come back in my application. Initially the map appears and there is a blue circle while it is getting a fine location. However, instead of resolving to a point, the circle just disappears.
My Code looks like this:
onResume() {
myLocation = new MyLocationOverlay(getActivity(), mp);
myLocation.enableMyLocation();
myLocation.runOnFirstFix(new Runnable(){
public void run() {
map.getOverlays().clear();
map.getOverlays().add(myLocation);
map.postInvalidate();
}
}
}
onPause() {
myLocation.disableMyLocation();
layout.removeView(map);
map = null;
}
Does anyone have any thoughts on what might be happening here? Since this is pretty much verbatim what all the examples online look like, I might add that I am testing this on a motorolla atrix running 2.3.4.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编辑:
让我带您浏览一下您的代码:圆圈
map.getOverlays().clear();
使用remove()
删除 删除您不需要的覆盖层,而不是全部清除。每当需要强制重绘时,请记住调用
map.invalidate();
Edit :
Let me take you through your code:map.getOverlays().clear();
removes the circleuse
remove()
instead to remove the overlay(s) that you don't want, instead of clearing them all.Remember to call
map.invalidate();
whenever you need to force a redraw