@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.my_map); setResult(RESULT_OK); mMap = (MapView) findViewById(R.id.myGmap); mMap.setBuiltInZoomControls(true); mMap.setSatellite(false); mController = mMap.getController(); Bundle extras = getIntent().getExtras(); double glat = 0; double glon = 0; if (extras != null) { name = extras.getString("Name"); glat = extras.getDouble("lat"); glon = extras.getDouble("lon"); } else Toast.makeText(this, "Error while getting train position", Toast.LENGTH_LONG).show(); // Toast.makeText(this, glat + " // " + glon, Toast.LENGTH_LONG).show(); gpStation = new GeoPoint((int) (glat * 1E6), (int) (glon * 1E6)); marker = getResources().getDrawable(R.drawable.ic_station_pixelart); stationsOverlay = new ItemizedOverlayStation(marker, name, this); stationsOverlay.addPoint(gpStation); mMap.getOverlays().add(stationsOverlay); mController.setCenter(gpStation); mController.setZoom(15); // adding me= MyLocation(GPS) and also a compass ... myLocationOverlay = new FixedMyLocationOverlay(this, mMap); myLocationOverlay.enableMyLocation(); myLocationOverlay.enableCompass(); mMap.getOverlays().add(myLocationOverlay); stationDetailDialog(name, 0); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.googlemaps); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); MapView mapView = (MapView) findViewById(R.id.mapview); mapView.setBuiltInZoomControls(true); MapController mapController = mapView.getController(); GeoPoint point = new GeoPoint(42295938, -71297368); mapController.setCenter(point); mapController.setZoom(15); List<Overlay> mapOverlays = mapView.getOverlays(); Drawable drawable = this.getResources().getDrawable(R.drawable.maparrow); MapItemizedOverlay itemizedoverlay = new MapItemizedOverlay(drawable, this); OverlayItem overlayitem = new OverlayItem(point, "Wellesley Books!", "82 Central St.\nWellesley, MA 02482"); itemizedoverlay.addOverlay(overlayitem); mapOverlays.add(itemizedoverlay); }