MapView latitudeSpan / longtitudeSpan 不起作用
我试图获取地图视图的边界,但遇到的问题是纬度始终设置为 0,经度始终设置为 360*1E6。根据此链接,这是因为它只会在地图完全加载时提供正确的坐标: Mapview getLatitudeSpan 和 getLongitudeSpan 不起作用
现在,我对解决方案完全感到困惑,我创建了从主活动(地图视图)的 onCreate 中调用的方法:
public int[][] getBounds()
{
GeoPoint center = this.mapView.getMapCenter();
int latitudeSpan = this.mapView.getLatitudeSpan();
int longtitudeSpan = this.mapView.getLongitudeSpan();
int[][] bounds = new int[2][2];
bounds[0][0] = center.getLatitudeE6() + (latitudeSpan/2);
bounds[0][1] = center.getLongitudeE6() + (longtitudeSpan/2);
bounds[1][0] = center.getLatitudeE6() - (latitudeSpan/2);
bounds[1][1] = center.getLongitudeE6() - (longtitudeSpan/2);
return bounds;
}
如何使其等待地图视图加载?我查看了 postDelayed 的 API,但无法让它工作。
如果我很蠢请原谅我
I am trying to get the bounds of my mapview but I had the problem that the latitude is always set to 0 and longtitude is always set to 360*1E6. According to this link, that is because it will only offer the right coordinates when the map is fully loaded:
Mapview getLatitudeSpan and getLongitudeSpan not working
Now, I am totally confused about the solution, I made this method which I call from the onCreate of my mainactivity (the mapview):
public int[][] getBounds()
{
GeoPoint center = this.mapView.getMapCenter();
int latitudeSpan = this.mapView.getLatitudeSpan();
int longtitudeSpan = this.mapView.getLongitudeSpan();
int[][] bounds = new int[2][2];
bounds[0][0] = center.getLatitudeE6() + (latitudeSpan/2);
bounds[0][1] = center.getLongitudeE6() + (longtitudeSpan/2);
bounds[1][0] = center.getLatitudeE6() - (latitudeSpan/2);
bounds[1][1] = center.getLongitudeE6() - (longtitudeSpan/2);
return bounds;
}
How do I make this wait for the mapview to load? I've looked in the API for postDelayed, but I cannot get it to work.
Forgive me if I am being stupid o.o'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 android 中创建“定时器”的正确方法是使用 android.os.Handler:
The correct way to create a "Timer" in android is to utilize
android.os.Handler
: