Sliding drawer over MapView

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

Sliding drawer over MapView

Postby nick_wa » Tue Mar 09, 2010 10:12 pm

Hey guys, been reading here for a while and we are now creating our first application and need some help.

We are trying to get a sliding drawer to roll up over a mapView. Our application starts, opens the mapView, zooms to current location and displays a menu to the user to enter start/end addresses. Upon entering, hit the button and we do some stuff.

We want to be able to get the drawer to come up and down over the mapView but all I can seem to get is it to come up if I inflate and set the content view to it but then mapView is gone. I can only get one or the other, not both. Anybody have any advice? I am not great with views, layouts, that sort of thing.

Thanks alot in advance!! (Sorry if my code is not great but right now it is working (see the last lines of the java file for where we are having issues!)

DRAWER.XML

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8" ?>
  3.  
  4.         <FrameLayout android:layout_width="fill_parent"
  5.  
  6.         android:layout_height="fill_parent"
  7.  
  8.         xmlns:android="http://schemas.android.com/apk/res/android"
  9.  
  10.         android:id="@+id/frameLayout">
  11.  
  12.                 <SlidingDrawer android:layout_height="wrap_content"
  13.  
  14.                 android:handle="@+id/handle" android:content="@+id/content"
  15.  
  16.                 android:id="@+id/slide" android:orientation="vertical"
  17.  
  18.                 android:layout_width="fill_parent">
  19.  
  20.                         <ImageView android:layout_width="wrap_content"
  21.  
  22.                         android:layout_height="wrap_content"
  23.  
  24.                         android:id="@id/handle"
  25.  
  26.                         android:src="@drawable/icon" />
  27.  
  28.                                 <LinearLayout android:layout_width="fill_parent"
  29.  
  30.                                 android:layout_height="wrap_content"
  31.  
  32.                                 android:orientation="vertical"
  33.  
  34.                                 android:id="@id/content"
  35.  
  36.                                 android:background="@color/eden_dark">
  37.  
  38.                                         <Button android:text="Go To Destination!"
  39.  
  40.                                         android:id="@+id/Button01"
  41.  
  42.                                         android:layout_width="fill_parent"
  43.  
  44.                                         android:layout_height="wrap_content" />
  45.  
  46.                                         <EditText android:gravity="center"
  47.  
  48.                                         android:hint="Enter Destination Here"
  49.  
  50.                                         android:id="@+id/dest01"
  51.  
  52.                                         android:layout_width="fill_parent"
  53.  
  54.                                         android:layout_height="wrap_content" />
  55.  
  56.                                         <Button android:text="Check Traffic"
  57.  
  58.                                         android:id="@+id/Button02"
  59.  
  60.                                         android:layout_width="fill_parent"
  61.  
  62.                                         android:layout_height="wrap_content"/>
  63.  
  64.                                         <Button android:text="Points of Interest"
  65.  
  66.                                         android:id="@+id/Button03"
  67.  
  68.                                         android:layout_width="fill_parent"
  69.  
  70.                                         android:layout_height="wrap_content"/>
  71.  
  72.                                         <TextView android:gravity="center"
  73.  
  74.                                         android:text="Map View"
  75.  
  76.                                         android:id="@+id/MapViewTitle"
  77.  
  78.                                         android:layout_width="fill_parent"
  79.  
  80.                                         android:layout_height="wrap_content"/>
  81.  
  82.                                         <RadioButton android:text="Standard View"
  83.  
  84.                                         android:id="@+id/MapVButton"
  85.  
  86.                                         android:layout_width="wrap_content"
  87.  
  88.                                         android:layout_height="wrap_content"/>
  89.  
  90.                                         <RadioButton android:text="Satellite View"
  91.  
  92.                                         android:id="@+id/SatVButton"
  93.  
  94.                                         android:layout_width="wrap_content"
  95.  
  96.                                         android:layout_height="wrap_content"/>
  97.  
  98.                                         <RadioButton android:text="Traffic View"
  99.  
  100.                                         android:id="@+id/TraVButton"
  101.  
  102.                                         android:layout_width="wrap_content"
  103.  
  104.                                         android:layout_height="wrap_content"/>
  105.  
  106.                                 </LinearLayout>
  107.  
  108.                 </SlidingDrawer>
  109.  
  110. </FrameLayout>
  111.  
  112.  
Parsed in 0.008 seconds, using GeSHi 1.0.8.4


MAIN CLASS

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public class GPSActivity extends MapActivity {
  3.  
  4.        private Road mRoad;
  5.  
  6.        MapView mapView;
  7.  
  8.        MapController mapController;
  9.  
  10.        LocationManager locationManager;
  11.  
  12.        LocationListener locationListener;
  13.  
  14.    
  15.  
  16.     public void onCreate(Bundle savedInstanceState) {
  17.  
  18.         super.onCreate(savedInstanceState);    
  19.  
  20.         setContentView(R.layout.main);
  21.  
  22.         mapView = (MapView) findViewById(R.id.mapView);
  23.  
  24.         mapView.setBuiltInZoomControls(true);
  25.  
  26.         mapController = mapView.getController();
  27.  
  28.         locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
  29.  
  30.         locationListener = new MyLocationListener();
  31.  
  32.         locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,3000,5,locationListener);
  33.  
  34.        
  35.  
  36.    
  37.  
  38.         final EditText userDest=(EditText)findViewById(R.id.userDestAddress);
  39.  
  40.         final EditText userSrc=(EditText)findViewById(R.id.userSrcAddress);
  41.  
  42.         Button goButton=(Button)findViewById(R.id.goEnterDest);
  43.  
  44.        
  45.  
  46.         LayoutInflater inflater = getLayoutInflater();
  47.  
  48.         View drawerView = inflater.inflate(R.layout.drawer, null);
  49.  
  50.         setContentView(drawerView);
  51.  
  52.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4



MAIN.XML

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  5.  
  6.    android:orientation="vertical"
  7.  
  8.    android:layout_width="fill_parent"
  9.  
  10.    android:layout_height="fill_parent"
  11.  
  12.    android:background="@color/translucent_white">
  13.  
  14.    
  15.  
  16.     <EditText android:id="@+id/userSrcAddress"
  17.  
  18.                   android:layout_width="fill_parent"
  19.  
  20.                   android:layout_height="wrap_content"
  21.  
  22.                   android:hint="Enter Source! (Blank for Current)"/>          
  23.  
  24.  
  25.  
  26.         <EditText android:id="@+id/userDestAddress"
  27.  
  28.              android:layout_width="fill_parent"
  29.  
  30.              android:layout_height="wrap_content"
  31.  
  32.              android:hint="Enter Destination!"/>
  33.  
  34.              
  35.  
  36.         <Button android:id="@+id/goEnterDest"
  37.  
  38.                         android:layout_width="100px"
  39.  
  40.                 android:layout_height="wrap_content"
  41.  
  42.                 android:layout_gravity="center_horizontal"
  43.  
  44.                 android:layout_toRightOf="@id/userDestAddress"
  45.  
  46.            android:layout_alignTop="@id/userDestAddress"
  47.  
  48.                 android:text="Go"/>    
  49.  
  50.                        
  51.  
  52.         <com.google.android.maps.MapView
  53.  
  54.                 android:id = "@+id/mapView"
  55.  
  56.                 android:layout_width = "fill_parent"
  57.  
  58.                 android:layout_height = "fill_parent"
  59.  
  60.                 android:enabled = "true"
  61.  
  62.                 android:clickable="true"
  63.  
  64.                 android:apiKey="***"/>
  65.  
  66.    
  67.  
  68.  
  69.  
  70. </LinearLayout>
  71.  
  72.  
Parsed in 0.004 seconds, using GeSHi 1.0.8.4
nick_wa
Junior Developer
Junior Developer
 
Posts: 15
Joined: Tue Mar 09, 2010 9:51 pm

Top

Postby wium » Tue Mar 23, 2010 10:12 am

Hi,

I have been struggling with the same problem . Try to switch :
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. setContentView(drawerView);
  3.  
  4.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4

with
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. getWindow().addContentView(inflatetDrawerLayout, parms);
  3.  
  4.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
wium
Freshman
Freshman
 
Posts: 2
Joined: Sat Jan 30, 2010 4:04 pm

Re: Sliding drawer over MapView

Postby tsumons » Sun Oct 31, 2010 9:14 pm

I agree with wium! Just to clarify:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. View inflatedDrawerLayout = getLayoutInflater().inflate(R.layout.drawer, null);
  2. int width = getWindow().getAttributes().width, height = getWindow().getAttributes().height;
  3. LayoutParams params = new LayoutParams(width, height);
  4. getWindow().addContentView(inflatedDrawerLayout, params);
  5.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4

The width and height specify the area the drawer is allotted for sliding into--not the actual size of the handle or content--so if you want it to slide all the way out from the middle of the edge, use the full window dimensions as I did here.
tsumons
Once Poster
Once Poster
 
Posts: 1
Joined: Sun Oct 31, 2010 9:04 pm

Re: Sliding drawer over MapView

Postby chesterjames » Thu Nov 11, 2010 5:56 pm

Not tried it myself personally but I believe you can use AnimationDrawable as a map overlay http://developer.android.com/reference/ ... wable.html

If that's not what you're after, this may be of some interest
http://blog.pocketjourney.com/2008/03/1 ... oogle-map/
chesterjames
Junior Developer
Junior Developer
 
Posts: 12
Joined: Tue Nov 09, 2010 11:32 pm

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 2 guests