我正在实现一个基于 map 的 Android 应用程序。因为我试图在左上角和右下角显示引脚。以下是我尝试过的代码。但我无法显示它。您能否建议一种获取这些坐标的方法。
public GeoPoint topLeft(GeoPoint mapCenter, int latspan, int langspan) {
int lat = (mapCenter.getLatitudeE6()) + (latspan/2);
int lang = (mapCenter.getLongitudeE6()) - (langspan/2);
return new GeoPoint(lat, lang);
}
public GeoPoint bottomRight(GeoPoint mapCenter, int latspan, int langspan) {
int lat = (mapCenter.getLatitudeE6()) - (latspan/2);
int lang = (mapCenter.getLongitudeE6()) + (langspan/2);
return new GeoPoint(lat, lang);
}
最佳答案
你在找这样的东西吗?
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;
希望对您有所帮助!
关于java - Android SDK中MapView的左上右下经纬度值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4378051/