/[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 370 - (hide annotations) (download)
Wed Sep 30 18:12:04 2009 UTC (14 years, 8 months ago) by torben
File size: 1992 byte(s)
Disable gps when leaving map activity
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     import android.util.Log;
9    
10     import com.google.android.maps.MapActivity;
11     import com.google.android.maps.MapController;
12     import com.google.android.maps.MapView;
13 torben 369 import com.google.android.maps.MyLocationOverlay;
14     import com.google.android.maps.Overlay;
15 torben 368
16     import dk.thoerup.traininfo.R;
17    
18     public class StationMapView extends MapActivity {
19    
20     MapView mapView;
21    
22     MapController mapController;
23 torben 370 MyLocationOverlay myLocation;
24 torben 368
25     @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    
38    
39    
40     Intent launchedBy = getIntent();
41    
42     GeoPair userLocation = (GeoPair) launchedBy.getSerializableExtra("userlocation");
43     Log.i("MapView", "" + userLocation.getLatitude() + "," + userLocation.getLongitude());
44     mapController.setCenter( userLocation.toGeopoint() );
45    
46 torben 369 Drawable defaultIcon = getResources().getDrawable(R.drawable.train_24);
47     StationOverlay stationOverlay = new StationOverlay(defaultIcon, this);
48 torben 368
49     List<GeoPair> stations = (List<GeoPair>) launchedBy.getSerializableExtra("stations");
50     stationOverlay.addStations( stations );
51    
52 torben 369 List<Overlay> overlays = mapView.getOverlays();
53     overlays.add( stationOverlay );
54    
55 torben 370 myLocation = new MyLocationOverlay(this,mapView);
56    
57 torben 369
58     overlays.add( myLocation );
59 torben 368 }
60    
61    
62     @Override
63 torben 370 protected void onPause() {
64     super.onPause();
65     myLocation.disableMyLocation();
66     }
67    
68    
69     @Override
70     protected void onResume() {
71     super.onResume();
72     myLocation.enableMyLocation();
73     }
74    
75    
76     @Override
77 torben 368 protected boolean isRouteDisplayed() {
78     return false;
79     }
80    
81     }

  ViewVC Help
Powered by ViewVC 1.1.20