Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了如何缩放相机以覆盖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 googlemap中的路径?全部内容,希望文章能够帮你解决如何缩放相机以覆盖Android googlemap中的路径?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。