package dk.thoerup.traininfo.stationmap; import java.util.List; import android.content.Intent; import android.graphics.drawable.Drawable; import android.os.Bundle; import com.google.android.maps.MapActivity; import com.google.android.maps.MapController; import com.google.android.maps.MapView; import com.google.android.maps.MyLocationOverlay; import com.google.android.maps.Overlay; import dk.thoerup.traininfo.R; public class StationMapView extends MapActivity { MapView mapView; MapController mapController; MyLocationOverlay myLocation; @SuppressWarnings("unchecked") @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.stationmap); mapView = (MapView) findViewById(R.id.mapview); mapView.setBuiltInZoomControls(true); mapView.setSatellite(false); mapController = mapView.getController(); mapController.setZoom(12); Intent launchedBy = getIntent(); Drawable defaultIcon = getResources().getDrawable(R.drawable.train_24); StationOverlay stationOverlay = new StationOverlay(defaultIcon, this); List stations = (List) launchedBy.getSerializableExtra("stations"); stationOverlay.addStations( stations ); List overlays = mapView.getOverlays(); overlays.add( stationOverlay ); myLocation = new MyLocationOverlay(this,mapView); myLocation.runOnFirstFix( new Runnable() { @Override public void run() { mapController.setCenter( myLocation.getMyLocation() ); } }); overlays.add( myLocation ); } @Override protected void onPause() { super.onPause(); myLocation.disableMyLocation(); } @Override protected void onResume() { super.onResume(); myLocation.enableMyLocation(); } @Override protected boolean isRouteDisplayed() { return false; } }