我使用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)); }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。