简体   繁体   English

如何使用地图中心的zoomLevel和LatLng计算MapView的LatLngBounds?

[英]How to calculate LatLngBounds of the MapView with zoomLevel and LatLng of map center?

I have found many discussions about given LatLngBounds, how to get a fit zoom level. 我发现了很多有关给定LatLngBounds的讨论,如何获得合适的缩放级别。 But now I meet a problem that I know current location of map center, and I can get what current zoom level is, and I wanna know the LatLng of the north-east corner and the south-west corner of my map view. 但是现在我遇到一个问题,我知道地图中心的当前位置,并且可以获得当前的缩放级别,并且我想知道地图视图的东北角和西南角的LatLng。

Any ideas? 有任何想法吗? Thanks. 谢谢。

You can get the Projection of the map and the VisibleRegion : 您可以获取地图的ProjectionVisibleRegion

VisibleRegion visibleRegion = mMap.getProjection().getVisibleRegion();

Then you can get the VisibleRegion 's farLeft , farRight , nearLeft and nearRight coordinates. 然后,您可以获取VisibleRegionfarLeftfarRightnearLeftnearRight坐标。 So, if you need a LatLngBounds you can do: 因此,如果您需要LatLngBounds ,则可以执行以下操作:

LatLngBounds mapBounds = new LatLngBounds(visibleRegion.farLeft, visibleRegion.nearRight);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM