Google地图应用程序

时间:2011-06-12 12:27:36

标签: android

我正在尝试与谷歌地图相关的应用程序。虽然做了那个应用程序我遇到了一些问题。这是我的xml文件

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

  <com.google.android.maps.MapView 
    android:id="@+id/mapView"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:enabled="true"
     android:clickable="true"
     android:apiKey="0uw2roKAecBgrtyYUPVL-pJ84Ez4tfHTilFZCGw"/>
      <LinearLayout android:id="@+id/zoom" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true" 
    /> 
  </LinearLayout>

这是我的.java文件

protected void onCreate(Bundle icicle) {


    super.onCreate(icicle);
    setContentView(R.layout.main);
    mapView = (MapView) findViewById(R.id.mapView);
              LinearLayout zoomLayout = (LinearLayout)findViewById(R.id.zoom);  
              View zoomView = mapView.getZoomControls();
              zoomLayout.addView(zoomView, 
              new LinearLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT, 
                LayoutParams.WRAP_CONTENT)); 
        mapView.displayZoomControls(true);
}

我正在获取此应用程序的谷歌地图视图,但没有缩放。 如果我先改变,我正在使用缩放选项输出..线性布局的问题是什么。请告诉我的朋友

3 个答案:

答案 0 :(得分:0)

控制缩放,平移和您需要定义的其他操作

MapController mapController = mapView.getController();

:)

答案 1 :(得分:0)

在onCreate中尝试:

mapView.setBuiltInZoomControls(true);

答案 2 :(得分:0)

首先,我认为您想要使用,将最外层布局更改为相对。 LinearLayout的问题在于你忘了放置重量。 将android:layout_weight="1"提供给mapview,将android:layout_weight="0"提供给zooom控件布局。

相关问题