0

我将 GooglepMap V2 嵌入到我的 Android APP (2.2) 中,但是当我尝试在我的设备中进行缩放或导航到地图时,移动速度太慢,有时事件(缩放或导航)不起作用. 我可以在传播事件时遇到问题吗?这可能是问题所在?

布局图:

<RelativeLayout  
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<fragment
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.google.android.gms.maps.SupportMapFragment"/>

</RelativeLayout>

谷歌地图活动:

public class GoogleMapActivity extends FragmentActivity{

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.template);
    LinearLayout l = (LinearLayout)  findViewById(R.id.info);
    LinearLayout left = new LinearLayout(this);
    ...
    LinearLayout right = new LinearLayout(this);
    ...
    addMap(right);   
    l.addView(right);
}

RelativeLayout mapRelative;
private final LatLng UPV = new LatLng(39.481106, -0.340987);
private GoogleMap mapa;

public void addMap(LinearLayout main){      
    LayoutInflater inflater = LayoutInflater.from(GoogleMapActivity.this);
    mapRelative = (RelativeLayout)inflater.inflate(R.layout.map, null, false);
    main.addView(mapRelative);
}

@Override
protected void onResume() {
    super.onResume();

    mapa = ((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map))
    .getMap();
    if (mapa != null) {
      mapa.setMapType(GoogleMap.MAP_TYPE_NORMAL);
      mapa.moveCamera(CameraUpdateFactory.newLatLngZoom(UPV, 15));
      mapa.setMyLocationEnabled(true);
      mapa.getUiSettings().setAllGesturesEnabled(true);
}
}
}
4

1 回答 1

0

我发现了问题!我正在使用“R.layout.template”将地图嵌套到 ScrollView 中。然后我删除了 ScrollView。

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@android:color/white" >   
<LinearLayout 
    android:id="@+id/info"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:focusableInTouchMode="true"
>
</LinearLayout>
</ScrollView>
于 2013-06-25T02:58:12.490 回答