单击标记时,导航“和”GPS指针“按钮不可见

时间:2016-08-03 07:24:18

标签: android google-maps

我有一个带有自定义信息窗口的谷歌地图。此外,我还添加了一些逻辑,用于在单击标记/引脚时使信息窗口居中。从我所看到的问题是覆盖setOnMarkerClickListener。虽然我明确设置mMap.getUiSettings().setMapToolbarEnabled(true); 它不起作用。这是我的代码:

mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {

        @Override
        public boolean onMarkerClick(final Marker marker) {

            // Description: Get device height
            // ------------------------------------------------------------------------------------
            WindowManager wm = (WindowManager) view.getContext().getSystemService(Context.WINDOW_SERVICE);
            Display display = wm.getDefaultDisplay();
            Point size = new Point();
            display.getSize(size);
            int height = size.y;

            // Description: Move the camera up so title of info window is visible
            // ------------------------------------------------------------------------------------
            LatLng markerLocation = marker.getPosition();
            Point mappoint = mMap.getProjection().toScreenLocation(new LatLng(markerLocation.latitude, markerLocation.longitude));
            mappoint.set(mappoint.x, mappoint.y - (height / 3));

            CameraUpdate cu = CameraUpdateFactory.newLatLng(mMap.getProjection().fromScreenLocation(mappoint));

            mMap.getUiSettings().setMapToolbarEnabled(true);

            mMap.animateCamera(cu, new GoogleMap.CancelableCallback() {

                @Override
                public void onFinish() {
                    if (marker != null) {

                        marker.showInfoWindow();

                        mMap.getUiSettings().setMapToolbarEnabled(true);
                    }
                }

                @Override
                public void onCancel() {
                }
            });

            return true;
        }
    });

1 个答案:

答案 0 :(得分:2)

我遇到了这个问题,在你的onMarkerClick上返回false,这样就会显示默认行为。