yoshi24
yoshi24

Reputation: 3177

MapView isn't showing up with this?

I have this layout in xml. And when I run the activity at the bottom nothing shows up except the buttons.

<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:orientation="vertical"
 android:layout_height="fill_parent">
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:orientation="horizontal"
android:layout_height="fill_parent">


    <Button
    android:id="@+id/sat"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Satellite"
    android:onClick="myClickHandler"
    android:padding="8px"/>
    <Button
    android:id="@+id/street"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Street"
    android:onClick="myClickHandler"
    android:padding="8px"/>
    <Button
    android:id="@+id/traffic"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Traffic"
    android:onClick="myClickHandler"
    android:padding="8px"/>
    <Button
    android:id="@+id/normal"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Normal"
    android:onClick="myClickHandler"
    android:padding="8px"/>
 </LinearLayout>

<com.google.android.maps.MapView
android:id="@+id/mapView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:apiKey=
/>
 </LinearLayout>

For some reason the only thingI can see is the buttons at the top. the map doesn't show up when my activity is ran.

Here is my code in the MapActivity also.

public class meeting_map extends MapActivity{
private MapView mapView;

@Override
protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.mapview);

    mapView = (MapView)findViewById(R.id.mapView);
    mapView.setBuiltInZoomControls(true);
}
public void myClickHandler(View target){
    switch(target.getId()){
    case R.id.sat:
        mapView.setSatellite(true);
        break;
    case R.id.street:
        mapView.setStreetView(true);
        break;
    case R.id.traffic:
        mapView.setTraffic(true);
        break;
    case R.id.normal:
        mapView.setSatellite(false);
        mapView.setTraffic(false);
        mapView.setStreetView(false);
        break;

    }
}
@Override
  protected boolean isLocationDisplayed(){
    return false;
}
@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}


}

Maybe I'm missing something.

Upvotes: 0

Views: 1122

Answers (1)

Matthias
Matthias

Reputation: 240

If you change android:layout_height="fill_parent" of the 2nd LinearLayout to android:layout_height="wrap_content" and android:layout_height="wrap_content" of the MapView to android:layout_height="fill_parent" then it should work (assuming that you have a valid API key + android.permission.INTERNET set in the AndroidManifest.xml file).

Upvotes: 1

Related Questions