如何使用与底部工作表适应的androd Maps Bounds

时间:2017-06-22 05:02:29

标签: java android maps bounds

在我的项目中,我有一个方法在地图内部绘制路径并为此路线创建边界,问题是,我需要使用底部工作表创建此边界而不是整个屏幕!

首先我打开底页:

private void openBottom(){
    if(latLngs != null){
        if(bottomSheetBehavior.getState() != BottomSheetBehavior.STATE_EXPANDED){
            bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
            bottomSheetBehavior.setPeekHeight(300);
        }
    }
}

然后画画和界限!

private void drawnNewRoute() {
    if(polyline == null){
        LatLngBounds.Builder builder = new LatLngBounds.Builder();

            po = new PolylineOptions();
            for(int i = 0, tam = latLngs.size(); i < tam; i++){
                po.add(latLngs.get(i));
                builder.include(latLngs.get(i));
            }
            String data = new Gson().toJson(latLngs);

            po.color(Color.BLACK).width(10);
            polyline = mMap.addPolyline(po);

            ArrayList<LatLng> latlang = new ArrayList<>();
            latlang.add(latLngs.get(0));
            latlang.add(latLngs.get(latLngs.size() -1));

            mMarkerNewPosition = mMap.addMarker(new MarkerOptions().position(finalLocaltion).title(finalLocationName));
            mMarkerNewPosition.showInfoWindow();

            mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 120));

            location_display_incl.setVisibility(View.GONE);

            stopLocation();
            InicialAddressTxt.setText(InicialAddress);
            double finalLat = latLngs.get(latLngs.size() -1).latitude;
            double finalLong = latLngs.get(latLngs.size() -1).longitude;

            try {
                ADRS = getAddress(finalLat,finalLong);
            } catch (IOException e) {
                e.printStackTrace();
            }

            FinalAddressTxt.setText(finalLocationName);
            String finalComp = ADRS.getLocality() + "," + address.getAdminArea();
            FinalComplement.setText(finalComp);
            //zoomToCoverAllMarkersInMap(latlang);
    }
    else{
        polyline.setPoints(latLngs);
    }
}

但它不断获得整个屏幕,而不仅仅是它的“可用”部分!

0 个答案:

没有答案