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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 369 - (show annotations) (download)
Wed Sep 30 16:40:48 2009 UTC (14 years, 7 months ago) by torben
File size: 1799 byte(s)
Draw user location on stationmap,
When a station icon is pressed, show the station name in a toaster box
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
24 @Override
25 protected void onCreate(Bundle icicle) {
26 super.onCreate(icicle);
27 setContentView(R.layout.stationmap);
28
29 mapView = (MapView) findViewById(R.id.mapview);
30 mapView.setBuiltInZoomControls(true);
31 mapView.setSatellite(false);
32
33
34 mapController = mapView.getController();
35 mapController.setZoom(12);
36
37
38
39 Intent launchedBy = getIntent();
40
41 GeoPair userLocation = (GeoPair) launchedBy.getSerializableExtra("userlocation");
42 Log.i("MapView", "" + userLocation.getLatitude() + "," + userLocation.getLongitude());
43 mapController.setCenter( userLocation.toGeopoint() );
44
45 Drawable defaultIcon = getResources().getDrawable(R.drawable.train_24);
46 StationOverlay stationOverlay = new StationOverlay(defaultIcon, this);
47
48 List<GeoPair> stations = (List<GeoPair>) launchedBy.getSerializableExtra("stations");
49 stationOverlay.addStations( stations );
50
51 List<Overlay> overlays = mapView.getOverlays();
52 overlays.add( stationOverlay );
53
54 MyLocationOverlay myLocation = new MyLocationOverlay(this,mapView);
55 myLocation.enableMyLocation();
56
57 overlays.add( myLocation );
58 }
59
60
61 @Override
62 protected boolean isRouteDisplayed() {
63 return false;
64 }
65
66 }

  ViewVC Help
Powered by ViewVC 1.1.20