我有一个 MapActivity。如果将其设置为适当的位置和缩放级别以查看流量,则在首次创建后不会显示任何内容,直到您与地图交互(单击它,拖动等),此时显示流量。自然,我希望流量在加载后无需任何用户交互即可显示,但我一直无法弄清楚如何触发它。有任何想法吗?
从我的 MapActivity 继承类:
private MapView mapView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
mapView.setTraffic(true);
}
这是 R.layout.map 中的内容
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainlayout"
android:orientation="vertical"
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:clickable="true"
android:apiKey="...MY API KEY HERE..."
/>
</RelativeLayout>