Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android 1.6 Mapview doesn't show traffic until user interacts with the map

I have a MapActivity. If it's set to an appropriate location and zoom level to see traffic none is shown after it's first created until you interact with the map (click on it, drag, etc) at which point traffic shows up. Naturally I want traffic to show up without any user interaction after it loads but I've been unable to figure out how to trigger it. Any ideas?

From my MapActivity inherited class:

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

And here's whats in 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>
like image 728
Brian Avatar asked Oct 25 '22 11:10

Brian


1 Answers

postInvalidate() after a suitable delay should do as a workaround, what kind of delay times have you tried?

like image 176
Steve Avatar answered Nov 11 '22 10:11

Steve