Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google maps Google Map Lite模式将摄影机移动到lat lng边界添加了不需要的贴图填充_Google Maps_Google Maps Android Api 2_Android Maps V2 - Fatal编程技术网

Google maps Google Map Lite模式将摄影机移动到lat lng边界添加了不需要的贴图填充

Google maps Google Map Lite模式将摄影机移动到lat lng边界添加了不需要的贴图填充,google-maps,google-maps-android-api-2,android-maps-v2,Google Maps,Google Maps Android Api 2,Android Maps V2,我想让地图摄影机移到我的后边界。因此,我将地图片段添加到BaseExpandableListAdapter的getChildView和onMapReady中的布局中,我将moveCamera移动到LatLngBounds @Override public View getChildView(final int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {

我想让地图摄影机移到我的后边界。因此,我将地图片段添加到
BaseExpandableListAdapter
getChildView
onMapReady
中的布局中,我将
moveCamera
移动到
LatLngBounds

@Override
public View getChildView(final int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {

    convertView = inflater.inflate(R.layout.event_child, parent, false);

    GoogleMapOptions options = new GoogleMapOptions();
    options.liteMode(true)
           .compassEnabled(false)
           .mapToolbarEnabled(false)
           .rotateGesturesEnabled(false)
           .tiltGesturesEnabled(false)
           .scrollGesturesEnabled(false)
           .zoomControlsEnabled(false)
           .zoomGesturesEnabled(false);

    SupportMapFragment mapFragment = SupportMapFragment.newInstance(options);
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.add(R.id.event_fragment_map, mapFragment, "event_fragment_map").commit();

    mapFragment.getMapAsync(new OnMapReadyCallback() {
        @Override
        public void onMapReady(GoogleMap googleMap) {
            mGoogleMap = googleMap;
            moveMapAddBounds();
        }
    });

//...
}

private void moveMapAddBounds(){
    mGoogleMap.addPolygon(new PolygonOptions().add(getLatLngBounds().southwest)
                                              .add(new LatLng(getLatLngBounds().northeast.latitude, getLatLngBounds().southwest.longitude))
                                              .add(getLatLngBounds().northeast)
                                              .add(new LatLng(getLatLngBounds().southwest.latitude, getLatLngBounds().northeast.longitude))
                         );
    mGoogleMap.moveCamera(CameraUpdateFactory.newLatLngBounds(getLatLngBounds(), 0));
}

public LatLngBounds getLatLngBounds() {
    //random fake latlng and distance
    LatLng from = new LatLng(51.1113564, 17.0041787);
    double distance = 1717.906494140625;
    return new LatLngBounds.Builder().
            include(SphericalUtil.computeOffset(from, distance, 0)).
            include(SphericalUtil.computeOffset(from, distance, 90)).
            include(SphericalUtil.computeOffset(from, distance, 180)).
            include(SphericalUtil.computeOffset(from, distance, 270)).build();
}
我正在根据计算边界,当在
moveMapAddBounds
中添加到地图的矩形被添加到有效位置时,它似乎工作正常,但地图相机被移动到几乎良好的位置,除了它向地图添加随机(?)填充(矩形上下对称),如图所示:


我观察到,对于特定的LatLngBounds,这些填充始终是相同的,但在不同的LatLngBounds之间它们是不同的。

原因是我使用了Lite模式,其中只有整数缩放可用


这种行为的可能原因: