Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了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 – 如何检测我的位置不再显示在地图上(导航后)?全部内容,希望文章能够帮你解决android – 如何检测我的位置不再显示在地图上(导航后)?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。