/[projects]/android/TrainInfo/src/dk/thoerup/traininfo/stationmap/StationMapView.java
ViewVC logotype

Annotation of /android/TrainInfo/src/dk/thoerup/traininfo/stationmap/StationMapView.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 489 - (hide annotations) (download)
Thu Oct 29 14:20:16 2009 UTC (14 years, 7 months ago) by torben
File size: 1924 byte(s)
Let the MylocationOverlay control where the map should be centered
1 torben 368 package dk.thoerup.traininfo.stationmap;
2    
3     import java.util.List;
4    
5     import android.content.Intent;
6 torben 369 import android.graphics.drawable.Drawable;
7 torben 368 import android.os.Bundle;
8    
9     import com.google.android.maps.MapActivity;
10     import com.google.android.maps.MapController;
11     import com.google.android.maps.MapView;
12 torben 369 import com.google.android.maps.MyLocationOverlay;
13     import com.google.android.maps.Overlay;
14 torben 368
15     import dk.thoerup.traininfo.R;
16    
17     public class StationMapView extends MapActivity {
18    
19     MapView mapView;
20    
21     MapController mapController;
22 torben 370 MyLocationOverlay myLocation;
23 torben 368
24 torben 489 @SuppressWarnings("unchecked")
25 torben 368 @Override
26     protected void onCreate(Bundle icicle) {
27     super.onCreate(icicle);
28     setContentView(R.layout.stationmap);
29    
30     mapView = (MapView) findViewById(R.id.mapview);
31     mapView.setBuiltInZoomControls(true);
32     mapView.setSatellite(false);
33    
34    
35     mapController = mapView.getController();
36     mapController.setZoom(12);
37 torben 489
38 torben 368 Intent launchedBy = getIntent();
39 torben 489
40 torben 369 Drawable defaultIcon = getResources().getDrawable(R.drawable.train_24);
41     StationOverlay stationOverlay = new StationOverlay(defaultIcon, this);
42 torben 368
43     List<GeoPair> stations = (List<GeoPair>) launchedBy.getSerializableExtra("stations");
44     stationOverlay.addStations( stations );
45    
46 torben 369 List<Overlay> overlays = mapView.getOverlays();
47     overlays.add( stationOverlay );
48    
49 torben 370 myLocation = new MyLocationOverlay(this,mapView);
50    
51 torben 489 myLocation.runOnFirstFix( new Runnable() {
52     @Override
53     public void run() {
54     mapController.setCenter( myLocation.getMyLocation() );
55     }
56     });
57    
58 torben 369
59     overlays.add( myLocation );
60 torben 368 }
61    
62    
63     @Override
64 torben 370 protected void onPause() {
65     super.onPause();
66     myLocation.disableMyLocation();
67     }
68    
69    
70     @Override
71     protected void onResume() {
72     super.onResume();
73     myLocation.enableMyLocation();
74     }
75    
76    
77     @Override
78 torben 368 protected boolean isRouteDisplayed() {
79     return false;
80     }
81    
82     }

  ViewVC Help
Powered by ViewVC 1.1.20