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

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

概述我使用LatLng.Builder在Google地图中覆盖了多个位置,并且它正在运行. 有什么方法可以覆盖谷歌地图中两个位置之间的整条路径吗? 我的Curent Code包含多个位置 builder = new LatLngBounds.Builder();builder.include(LatLng1);builder.include(LatLng2);googleMap.animateC 我使用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中的路径?所遇到的程序开发问题。

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

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1134395.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存