无论如何我可以获得一些位置信息forimateTo或MapView的当前中心,以便我以后可以恢复它?缩放级别也一样吗?
谢谢!
答案 0 :(得分:0)
使用sharedPreferences,查看此example的GetZoom()和SaveZoom()函数,您可以使用类似的东西
static final String PREFS_Zoom = "PREFS_Zoom";
private String zoomlevel;
private int Default_zoomlevel=100;
private void GetZoom(){
try{
SharedPreferences settings = getSharedPreferences(PREFS_Zoom,0);
zoomlevel = settings.getString("zoom_level","");
if (zoomlevel.length() >0)
Default_zoomlevel = Integer.parseInt(zoomlevel);
else
Default_zoomlevel =100;
}catch(Exception ex){
Log.e("******ZOOM ! ", "Exception GetZoom() ::"+ex.getMessage());
}
}
private void SaveZoom(){
try{
SharedPreferences settings = getSharedPreferences(PREFS_Zoom,0);
SharedPreferences.Editor editor = settings.edit();
Default_zoomlevel = (int) (mWebView.getScale() *100);
editor.putString("zoom_level",""+ Default_zoomlevel);
editor.commit();
}catch(Exception ex){
Log.e("******ZOOM ! ", "Exception SaveZoom() ::"+ex.getMessage());
}
}
UPDATE ::
MapView类有一个方法getZoomLevel(),它返回地图的当前缩放级别。 对于GeoPosition检查getLatitudeSpan()和getLongitudeSpan()方法