我将 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);
}
}
}