0

Is there anyway I can get some position information for animateTo or current center of the MapView so I can restore it later? Also the same for zoom level?

Thanks!

Heuristic
  • 5,087
  • 9
  • 54
  • 94

1 Answers1

0

Use sharedPreferences , see this example´s GetZoom() and SaveZoom() functions you can use something similar

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 Class has a method getZoomLevel() that returns the current zoom level of the map. for GeoPosition check getLatitudeSpan() and getLongitudeSpan() methods

Community
  • 1
  • 1
Jorgesys
  • 124,308
  • 23
  • 334
  • 268
  • I am looking at your code, but is there anyway I can get current zoom level of the MapView and geo position(or scroll X, Y) of the map? – Heuristic Jun 08 '11 at 00:12