1 |
package dk.thoerup.traininfo.stationmap;
|
2 |
|
3 |
import java.util.List;
|
4 |
|
5 |
import android.content.Intent;
|
6 |
import android.graphics.drawable.Drawable;
|
7 |
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 |
import com.google.android.maps.MyLocationOverlay;
|
14 |
import com.google.android.maps.Overlay;
|
15 |
|
16 |
import dk.thoerup.traininfo.R;
|
17 |
|
18 |
public class StationMapView extends MapActivity {
|
19 |
|
20 |
MapView mapView;
|
21 |
|
22 |
MapController mapController;
|
23 |
MyLocationOverlay myLocation;
|
24 |
|
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 |
Drawable defaultIcon = getResources().getDrawable(R.drawable.train_24);
|
47 |
StationOverlay stationOverlay = new StationOverlay(defaultIcon, this);
|
48 |
|
49 |
List<GeoPair> stations = (List<GeoPair>) launchedBy.getSerializableExtra("stations");
|
50 |
stationOverlay.addStations( stations );
|
51 |
|
52 |
List<Overlay> overlays = mapView.getOverlays();
|
53 |
overlays.add( stationOverlay );
|
54 |
|
55 |
myLocation = new MyLocationOverlay(this,mapView);
|
56 |
|
57 |
|
58 |
overlays.add( myLocation );
|
59 |
}
|
60 |
|
61 |
|
62 |
@Override
|
63 |
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 |
protected boolean isRouteDisplayed() {
|
78 |
return false;
|
79 |
}
|
80 |
|
81 |
}
|