如何在android中的mapview中获得四个角的long&lat值?

Pra*_*een 8 android google-maps overlayitem android-mapview

我在地图视图上工作.我想将叠加项放在地图视图上.覆盖项目全部取决于当前显示的地图视图和缩放级别.如何获取当前地图视图的四个角的经度和纬度以及如何分析其中的多少叠加项.我们还要检查缩放级别.任何想法?怎么做?

Sep*_*phy 11

我想你必须使用

mapview.getProjection().frompixel(intx, int y)
Run Code Online (Sandbox Code Playgroud)

对于屏幕的4个角(您可以通过mapView上的getwidth和getheight获取它们的坐标,并以(0,0),(getwidth(),0),(0,getheight())和(getwidth()开头) ,getheight())

这将为您提供4个地理点,您可以从中提取纬度和经度


yar*_*ian 7

如果您正在使用该google-play-servicesSupportMapFragment,特别是.

this.getMap()会给你一个GoogleMap(包装MapView)的实例

然后就是:

map.getProjection().getVisibleRegion();


Rea*_*oid 6

你在找这样的东西吗?

Projection proj = mapView.getProjection();
GeoPoint topLeft = proj.fromPixels(0, 0);

GeoPoint bottomRight = proj.fromPixels(mapView.getWidth()-1, mapView.getHeight()-1);

double topLat = topLeft.getLatitudeE6()/1E6;
double topLon = topLeft.getLongitudeE6()/1E6;
double bottomLat = bottomRight.getLatitudeE6()/1E6;
double bottomLon = bottomRight.getLongitudeE6()/1E6;
Run Code Online (Sandbox Code Playgroud)

希望能帮助到你!