我正在实施基于地图的Android应用程序。我试图在TopLeft和Bottom右侧显示引脚。以下是我尝试过的代码。但我无法显示它。你能否建议一种方法让这些人坐下来。
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);
}
答案 0 :(得分:2)
你在找这样的东西吗?
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;
希望它有所帮助!