简体   繁体   English

全屏Android Google Map v2,顶部和底部没有灰色网格

[英]Full screen Android google map v2 without grey grids on top and bottom

Using Android Google Maps v2 I want the map boundaries to match with phone screen width and height so that grey grids at the bottom and top of the map does not appear. 使用Android Google Maps v2,我希望地图边界与手机屏幕的宽度和高度匹配,以免在地图底部和顶部出现灰色网格。

Moreover I had idea which can be used as workaround to restrict the zoom level of map to certain level. 此外,我有想法可以用作解决方法,将地图的缩放级别限制为一定级别。 I can get the map zoom level with map.getCameraPosition().zoom But map.setZoom(..) is not available in google map v2. 我可以使用map.getCameraPosition()。zoom获取地图缩放级别,但是map.setZoom(..)在Google Map v2中不可用。 But how to set the Zoom ? 但是如何设置Zoom? Can we restrict the map to certain zoomIn level ? 我们可以将地图限制在一定的zoomIn级别吗?

Another question is related to android map repeat after itself after scrolling .Can we restrict it ?If not can we know the bounds or co ordinates or anything whether the map is starting again . 另一个问题与滚动后的android map重复之后有关。我们可以限制它吗?如果不能,我们是否知道边界或坐标或其他任何信息是否再次开始地图。

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

You can use this code to restrict the zoom level. 您可以使用此代码来限制缩放级别。 Here the minimum zoom level is set to 5. If the user tries to zoom out any further than the camera is animated back to the minimum level. 此处,最小缩放级别设置为5。如果用户尝试缩小的程度超过了将动画设置回最小级别的范围,则将其缩放到最小级别。 Just replace MIN_ZOOM with the value you want to be the minimum zoom level. 只需将MIN_ZOOM替换为您想要的最小缩放级别即可。

mMap.setOnCameraChangeListener(new OnCameraChangeListener() {
    @Override
    public void onCameraChange(CameraPosition cp) {             
        final float MIN_ZOOM = 5.0f;                

        if (cp.zoom < MIN_ZOOM){                
            CameraPosition cameraPosition = new CameraPosition.Builder()
                    .target(cp.target)                      
                    .bearing(cp.bearing)
                    .tilt(cp.tilt)      
                    .zoom(MIN_ZOOM) 
                    .build();                       

            mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));                  
        }
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM