android – 如何检测我的位置不再显示在地图上(导航后)?

我想在地图中添加一个按钮,将地图置于用户当前位置的中心,但只有当用户在地图中导航并且他的当前位置不再显示在地图上时,才应激活该按钮.
检测我使用onTouchEvent方法的导航.
@Override
public boolean onTouchEvent(MotionEvent event,MapView mapView) {

Log.e("Touch",Integer.toString(event.getAction()));

int action = event.getAction();
if (action == MotionEvent.ACTION_DOWN) {
    touchStarted = true;
} else if (action == MotionEvent.ACTION_MOVE) {

   if (event.getPointerCount() > 3)
     moveStarted = true;
    return true;

}
return true;
}

但我怎么检测到我的当前位置不再在屏幕上?

解决方法

其实我找到了一个更好的解决方案:
private void CheckVisibility(Marker myPosition)
{
    if(googleMap != null)
    {
        //This is the current user-viewable region of the map
        LatLngBounds bounds = googleMap.getProjection().getVisibleRegion().latLngBounds;

            if(bounds.contains(myPosition.getPosition()))
                   //If the item is within the the bounds of the screen

            else
                  //If the marker is off screen
    }
}

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...