单击标记时,摄像机的默认行为是将其置于屏幕中心,但由于我通常在信息窗口中有长文本描述,因此实际更改摄像机位置以使标记位于底部时更方便屏幕(使信息窗口位于屏幕中央).我想我应该能够通过覆盖onMarkerClick函数来做到这一点(当此函数返回true时,默认行为被取消)
@Override
public boolean onMarkerClick(final Marker marker) {
// Google sample code comment : We return false to indicate that we have not
// consumed the event and that we wish
// for the default behavior to occur (which is for the camera to move
// such that the
// marker is centered and for the marker's info window to open, if it
// has one).
marker.showInfoWindow();
CameraUpdate center=
CameraUpdateFactory.newLatLng(new LatLng(XXXX,
XXXX));
mMap.moveCamera(center);//my question is how to get this center …Run Code Online (Sandbox Code Playgroud) 我试图实现类似于谷歌地图导航的工作方式,请检查下图以供参考。在谷歌地图中,标记看起来位于静态位置,除非相机正在变化
。
为了实现这一点,我每次位置发生变化时都会对标记进行动画处理,然后通过在 Y 坐标中将其平移 -300px 将其定位到屏幕底部。
但我无法为相机设置动画以改变位置并同时将屏幕向下移动 300 像素。
当我为相机设置动画以改变位置时,标记会精确地移动到屏幕中心,稍后当我将相机移动到低于其他动画 300 像素时,会发生其他动画,这看起来非常烦人。
有什么办法可以实现谷歌地图的功能吗?任何参考或帮助表示赞赏。