This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 20th, 2013  |  syntax: None  |  size: 2.05 KB  |  views: 104  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. package com.androidhive.googlemaps;
  2.  
  3. import java.util.List;
  4.  
  5. import android.graphics.drawable.Drawable;
  6. import android.os.Bundle;
  7.  
  8. import com.google.android.maps.GeoPoint;
  9. import com.google.android.maps.MapActivity;
  10. import com.google.android.maps.MapController;
  11. import com.google.android.maps.MapView;
  12. import com.google.android.maps.Overlay;
  13. import com.google.android.maps.OverlayItem;
  14.  
  15. public class AndroidGoogleMapsActivity extends MapActivity {
  16.     @Override
  17.     public void onCreate(Bundle savedInstanceState) {
  18.         super.onCreate(savedInstanceState);
  19.         setContentView(R.layout.main);
  20.        
  21.         // Displaying Zooming controls
  22.         MapView mapView = (MapView) findViewById(R.id.mapView);
  23.         mapView.setBuiltInZoomControls(true);
  24.        
  25.         /**
  26.          * Changing Map Type
  27.          * */
  28.         // mapView.setSatellite(true); // Satellite View
  29.         // mapView.setStreetView(true); // Street View
  30.         // mapView.setTraffic(true); // Traffic view
  31.        
  32.         /**
  33.          * showing location by Latitude and Longitude
  34.          * */        
  35.         MapController mc = mapView.getController();
  36.         double lat = Double.parseDouble("48.85827758964043");
  37.         double lon = Double.parseDouble("2.294543981552124");
  38.         GeoPoint geoPoint = new GeoPoint((int)(lat * 1E6), (int)(lon * 1E6));
  39.         mc.animateTo(geoPoint);
  40.         mc.setZoom(15);
  41.         mapView.invalidate();
  42.        
  43.        
  44.         /**
  45.          * Placing Marker
  46.          * */
  47.         List<Overlay> mapOverlays = mapView.getOverlays();
  48.         Drawable drawable = this.getResources().getDrawable(R.drawable.mark_red);
  49.         AddItemizedOverlay itemizedOverlay =
  50.              new AddItemizedOverlay(drawable, this);
  51.        
  52.        
  53.         OverlayItem overlayitem = new OverlayItem(geoPoint, "Hello", "Sample Overlay item");
  54.        
  55.         itemizedOverlay.addOverlay(overlayitem);
  56.         mapOverlays.add(itemizedOverlay);
  57.        
  58.     }
  59.  
  60.         @Override
  61.         protected boolean isRouteDisplayed() {
  62.                 return false;
  63.         }
  64. }
clone this paste RAW Paste Data