如何缩放相机以覆盖Android googlemap中的路径?

我使用LatLng.Builder在Google地图中覆盖了多个位置,并且它正在运行.
有什么方法可以覆盖谷歌地图中两个位置之间的整条路径吗?

我的Curent Code包含多个位置

builder = new LatLngBounds.Builder();
builder.include(LatLng1);
builder.include(LatLng2);
googleMap.animateCamera(CameraUpdateFactory.newLatLngBounds(builder.build(),17));

有什么建议吗?
谢谢

解决方法

我知道你已经找到了答案,但这是我解决问题的方法
boolean hasPoints = false;
        Double maxLat = null,minLat = null,minLon = null,maxLon = null;

        if (polyline != null && polyline.getPoints() != null) {
            List<LatLng> pts = polyline.getPoints();
            for (LatLng coordinate : pts) {
                // Find out the maximum and minimum latitudes & longitudes
                // Latitude
                maxLat = maxLat != null ? Math.max(coordinate.latitude,maxLat) : coordinate.latitude;
                minLat = minLat != null ? Math.min(coordinate.latitude,minLat) : coordinate.latitude;

                // Longitude
                maxLon = maxLon != null ? Math.max(coordinate.longitude,maxLon) : coordinate.longitude;
                minLon = minLon != null ? Math.min(coordinate.longitude,minLon) : coordinate.longitude;

                hasPoints = true;
            }
        }

        if (hasPoints) {
            LatLngBounds.Builder builder = new LatLngBounds.Builder();
            builder.include(new LatLng(maxLat,maxLon));
            builder.include(new LatLng(minLat,minLon));
            map.moveCamera(CameraUpdateFactory.newLatLngBounds(builder.build(),48));
        }

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...