2

这个帖子和这个很相似,目前没有解决方案(3岁)

主要问题是 GoogleMaps 似乎在我的地面覆盖图像周围添加了不必要的填充量,这对我来说没有意义,因为边界设置为与地面覆盖相同的纬度、经度。

@Override
public void onMapReady(GoogleMap googleMap) {

    final LatLngBounds NewarkBounds = new LatLngBounds(
            new LatLng(FILL, -FILL),
            new LatLng(FILL, -FILL)
    );

    mMap = googleMap;
    mMap.getUiSettings().setMapToolbarEnabled(false);
    mMap.getUiSettings().setZoomGesturesEnabled(false);
    mMap.getUiSettings().setMyLocationButtonEnabled(false);

    LatLng myPosition = new LatLng(latitude,longitude);


    GroundOverlayOptions newarkMap = new GroundOverlayOptions()
            .image(BitmapDescriptorFactory.fromResource(R.drawable.maptest))
            .positionFromBounds(NewarkBounds)
            .visible(true);

    mMap.addGroundOverlay(newarkMap);



    if((myPosition.latitude <= FILL&& myPosition.latitude >=FILL) && (myPosition.longitude >= -FILL&& myPosition.longitude <= -FILL)){
        mMap.setMyLocationEnabled(true);

    }
    else {
        mMap.setMyLocationEnabled(false);
    }

    mMap.setOnMyLocationButtonClickListener(this);
    mMap.setOnMyLocationClickListener(this);
    mMap.setMapType(0);


    /*
    int width = getResources().getDisplayMetrics().widthPixels;
    int height = getResources().getDisplayMetrics().heightPixels;
    int padding = (int) (width * 0.001); // offset from edges of the map 12% of screen

    CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(NewarkBounds, width, height, 0);
    mMap.animateCamera(cu);
    mMap.setPadding(0,0,0,0);
    mMap.setLatLngBoundsForCameraTarget(NewarkBounds);
    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(NewarkBounds.getCenter(), 17));
    // Set the camera to the greatest possible zoom level that includes the bounds

    */

    mMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
        @Override
        public void onMapLoaded() {
            // Set the camera to the greatest possible zoom level that includes the bounds
            mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(NewarkBounds, 0));
            //Centering the camera within bounds:
            mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(NewarkBounds.getCenter(), 17));
            //Restricting the user's scrolling and panning within bounds:
            mMap.setLatLngBoundsForCameraTarget(NewarkBounds);
        }
    });
}

我已经尝试了多种方法来解决这个问题,我发现可以将边界之外的不同坐标分配给地面叠加层,但这根本不正确。以下是当前显示的内容。

在此处输入图像描述

这就是我想要实现的

在此处输入图像描述

我会很感激关于这个问题的任何想法,因为它让我发疯。谢谢!

4

0 回答 0