简体   繁体   English

使用Mapbox查找左下角+右上角(纬度,经度)-[Android]

[英]Find the bottom left + upper right corners (latitude, longitude) with Mapbox - [Android]

Using MapBox in Android, I am trying to find the lower left corner and upper right corner. 我正在Android中使用MapBox,试图找到左下角和右上角。 I cannot find anywhere in their documentation to retrieve this information. 我在他们的文档中找不到任何地方可以检索此信息。

This line of code should accomplish what your trying to do: 这行代码应完成您的尝试:

LatLngBounds bounds = mapboxMap.getProjection().getVisibleRegion().latLngBounds;

EDIT 编辑

Sorry about that, This is a feature upcoming in 4.0. 抱歉,这是4.0中即将推出的功能。 for now you can use this as a work around: 现在您可以使用它来解决:

int viewportWidth = mMapView.getWidth();
int viewportHeight = mMapView.getHeight();

LatLng topLeft = mMapView.fromScreenLocation(new PointF(0, 0));
LatLng topRight = mMapView.fromScreenLocation(new PointF(viewportWidth, 0));
LatLng bottomRight = mMapView.fromScreenLocation(new PointF(viewportWidth, viewportHeight));
LatLng bottomLeft = mMapView.fromScreenLocation(new PointF(0, viewportHeight));

Hope this helps! 希望这可以帮助!

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

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