Layout with setBuiltInZoomControls()

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Layout with setBuiltInZoomControls()

Postby alfand » Thu Oct 08, 2009 8:02 am

Hi all,
I'm trying to show the ZoomControllers on my MapView using this method (since getZoomControls() is deprecated...). ZoomControls do display, but become visibile only when I click on the map (I suppose, in response to a unhandled TouchEvent) and automatically disappears after a while; moreover, they appear centered at the bottom of the MapView, while in the standard Maps application they are placed on the left, bottom angle.
Any hints?
Thanks :)

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.  
  3.  
  4.  
  5.  
  6. public class CustMapActivity extends MapActivity
  7.  
  8. {
  9.  
  10.         private MapController mc;
  11.  
  12.         private MapView mv;
  13.  
  14.  
  15.  
  16.        
  17.  
  18.         protected boolean isRouteDisplayed ()
  19.  
  20.         {
  21.  
  22.                 return false;
  23.  
  24.         }
  25.  
  26.        
  27.  
  28.        
  29.  
  30.         @Override
  31.  
  32.         public void onCreate (Bundle b)
  33.  
  34.         {
  35.  
  36.                 super.onCreate (b);
  37.  
  38.  
  39.  
  40.                 // set the layout defined in xml as the view for this activity
  41.  
  42.                 this.setContentView ( R.layout.maps_layout );
  43.  
  44.                
  45.  
  46.                 // get a reference to the MapView that was defined in the xml file
  47.  
  48.                 mv = (MapView) findViewById ( R.id.mapview );
  49.  
  50.                                                                
  51.  
  52.                 // display zoom buttons as embedded in the MapView
  53.  
  54.                 // ( preferred over getZoomControls(), which returns a View object to be added
  55.  
  56.                 // to the layout using add() )
  57.  
  58.         mv.setBuiltInZoomControls(true);
  59.  
  60.         mv.setSatellite(true);
  61.  
  62.                        
  63.  
  64.         // get the Controller for this map
  65.  
  66.         mc = mv.getController();
  67.  
  68.         mc.setZoom(14);                        
  69.  
  70.  
  71.  
  72.         ...
  73.  
  74.         }
  75.  
  76.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4



Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4.  
  5.  
  6. <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
  7.  
  8.    android:id="@+id/mainlayout"
  9.  
  10.    android:layout_width="fill_parent"
  11.  
  12.    android:layout_height="fill_parent">
  13.  
  14.  
  15.  
  16.     <com.google.android.maps.MapView
  17.  
  18.        android:id="@+id/mapview"
  19.  
  20.        android:layout_width="fill_parent"
  21.  
  22.        android:layout_height="fill_parent"        
  23.  
  24.        android:enabled="true"
  25.  
  26.        android:clickable="true"
  27.  
  28.         android:apiKey="..." />        
  29.  
  30.        
  31.  
  32. </AbsoluteLayout>
  33.  
  34.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4
alfand
Freshman
Freshman
 
Posts: 2
Joined: Sat Sep 05, 2009 1:06 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 7 guests