3
我怎样才能让我的MapView的屏幕坐标保存? (可见矩形左上和缩放级别) 我想稍后重新加载该坐标。我怎样才能做到这一点?Android如何让我的MapView的屏幕坐标? (可见矩形)
谢谢,莱斯利
我怎样才能让我的MapView的屏幕坐标保存? (可见矩形左上和缩放级别) 我想稍后重新加载该坐标。我怎样才能做到这一点?Android如何让我的MapView的屏幕坐标? (可见矩形)
谢谢,莱斯利
我不知道你是否已经找到了问题的答案,所以我会告诉你我的解决方案。我把下面的代码放在类MapView的子类中。
GeoPoint topLeft = this.getProjection().fromPixels(getLeft(), getTop());
GeoPoint bottomRight = this.getProjection().fromPixels(getRight(), getBottom());
int topLat = topLeft.getLatitudeE6();
int topLng = topLeft.getLongitudeE6();
int bottomLat = bottomRight.getLatitudeE6();
int bottomLng = bottomRight.getLongitudeE6();
我希望它能帮助你。
你不需要知道可见区域的坐标(你的角落MapView
)。屏幕的中心和缩放级别就足够了。
// obtain and persist this values
GeoPoint center = mapView.getMapCenter();
int zoomLevel = mapView.getZoomLevel();
// later restore them when you need
GeoPoint center = ...;
int zoomLevel = ...;
// and init your MapView with this values
MapController controller = mapView.getController();
controller.setZoom(zoomLevel);
controller.animateTo(center);
你是指经度和纬度? –
我的意思是我的mapview可见的矩形。代码如下:savedpointsonmap = mapview.getPointCoordsOnVisibleRectFromTopLeft();比mapview.setCoords(savedpointsonmap);或类似的东西......或者一种方法来保存我的可见矩形的左上角经度/纬度,然后加载该纬度/经度 – lacas