3 |
import java.util.List; |
import java.util.List; |
4 |
|
|
5 |
import android.content.Intent; |
import android.content.Intent; |
6 |
|
import android.graphics.drawable.Drawable; |
7 |
import android.os.Bundle; |
import android.os.Bundle; |
|
import android.util.Log; |
|
8 |
|
|
9 |
import com.google.android.maps.MapActivity; |
import com.google.android.maps.MapActivity; |
10 |
import com.google.android.maps.MapController; |
import com.google.android.maps.MapController; |
11 |
import com.google.android.maps.MapView; |
import com.google.android.maps.MapView; |
12 |
|
import com.google.android.maps.MyLocationOverlay; |
13 |
|
import com.google.android.maps.Overlay; |
14 |
|
|
15 |
import dk.thoerup.traininfo.R; |
import dk.thoerup.traininfo.R; |
16 |
|
|
19 |
MapView mapView; |
MapView mapView; |
20 |
|
|
21 |
MapController mapController; |
MapController mapController; |
22 |
|
MyLocationOverlay myLocation; |
23 |
|
|
24 |
|
@SuppressWarnings("unchecked") |
25 |
@Override |
@Override |
26 |
protected void onCreate(Bundle icicle) { |
protected void onCreate(Bundle icicle) { |
27 |
super.onCreate(icicle); |
super.onCreate(icicle); |
34 |
|
|
35 |
mapController = mapView.getController(); |
mapController = mapView.getController(); |
36 |
mapController.setZoom(12); |
mapController.setZoom(12); |
37 |
|
|
|
|
|
|
|
|
38 |
Intent launchedBy = getIntent(); |
Intent launchedBy = getIntent(); |
39 |
|
|
40 |
GeoPair userLocation = (GeoPair) launchedBy.getSerializableExtra("userlocation"); |
Drawable defaultIcon = getResources().getDrawable(R.drawable.train_24); |
41 |
Log.i("MapView", "" + userLocation.getLatitude() + "," + userLocation.getLongitude()); |
StationOverlay stationOverlay = new StationOverlay(defaultIcon, this); |
|
mapController.setCenter( userLocation.toGeopoint() ); |
|
|
|
|
|
StationOverlay stationOverlay = new StationOverlay(getResources().getDrawable(R.drawable.train_24)); |
|
|
|
|
|
stationOverlay.addUserLocation( userLocation ); |
|
42 |
|
|
43 |
List<GeoPair> stations = (List<GeoPair>) launchedBy.getSerializableExtra("stations"); |
List<GeoPair> stations = (List<GeoPair>) launchedBy.getSerializableExtra("stations"); |
44 |
stationOverlay.addStations( stations ); |
stationOverlay.addStations( stations ); |
45 |
|
|
46 |
mapView.getOverlays().add( stationOverlay ); |
List<Overlay> overlays = mapView.getOverlays(); |
47 |
|
overlays.add( stationOverlay ); |
48 |
|
|
49 |
|
myLocation = new MyLocationOverlay(this,mapView); |
50 |
|
|
51 |
|
myLocation.runOnFirstFix( new Runnable() { |
52 |
|
@Override |
53 |
|
public void run() { |
54 |
|
mapController.setCenter( myLocation.getMyLocation() ); |
55 |
|
} |
56 |
|
}); |
57 |
|
|
58 |
|
|
59 |
|
overlays.add( myLocation ); |
60 |
|
} |
61 |
|
|
62 |
|
|
63 |
|
@Override |
64 |
|
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 |
|
|