Android Google Maps:如何获取屏幕设备中当前显示的区域? [英] Android Google Maps: How to get the area which is currently shown in screen device?
问题描述
有没有一种方法可以获取设备上显示的当前区域的坐标?
Is there a way to get the coordinates of the current area, which is shown at the device?
背景是,我们要显示附近"的地点,这些地点存储在我们自己的数据库中.假设用户查看以下地图片段:
Background is, we want to show "nearby" places, which are stored in our own database. So let's say, the user looks at following clip of a map:
如何获取屏幕的经度/纬度(或屏幕中间的点和覆盖所有内容的半径?).请记住,地图中心通常不是当前位置,因为用户可以移动卡片的中心!
How do we get the longitude/latitude of the screen (or the point in the middle of the screen and a radius which covers everything?). Please keep in mind, center of the map is not usually the current position, since the user can move the center of the card!
推荐答案
使用map.getProjection().getVisibleRegion()
.从VisibleRegion
您可以获取LatLngBounds
,它很容易使用.您也可以直接尝试使用可能是梯形的区域.
Use map.getProjection().getVisibleRegion()
. From VisibleRegion
you can get LatLngBounds
, which is easy to work with. You may also try directly with the region, which might be trapezoid.
这篇关于Android Google Maps:如何获取屏幕设备中当前显示的区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!