Exemplo n.º 1
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // MapView and Controller
    map = (MapView) findViewById(R.id.map);
    map.setBuiltInZoomControls(true);
    myMapController = map.getController();
    myMapController.setZoom(17);

    // MyLocationOverlay
    myLocationOverlay = new MyLocationOverlay(this, map);
    myLocationOverlay.enableMyLocation();
    map.getOverlays().add(myLocationOverlay);

    // Get Overlays
    mapOverlays = map.getOverlays();
    drawable = this.getResources().getDrawable(R.drawable.marker);
    itemizedOverlay = new HelloItemizedOverlay(drawable);

    // Add Marker on RP E6
    GeoPoint point = new GeoPoint(1445450, 103784260);
    OverlayItem overlayitem = new OverlayItem(point, "Hello!", "This is Republic Polytechnic E6");

    itemizedOverlay.addOverlay(overlayitem);
    mapOverlays.add(itemizedOverlay);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.map);

    MapView mapView = (MapView) findViewById(R.id.map);

    Intent prevIntent = getIntent();
    Bundle bundle = prevIntent.getExtras();
    JOBearingBPOI poi = (JOBearingBPOI) bundle.getSerializable(JOBearingConfig.DESTINATION);

    GeoPoint point = new GeoPoint((int) (poi.getLat() * 10E5), (int) (poi.getLon() * 10E5));

    Drawable drawable = this.getResources().getDrawable(R.drawable.ic_launcher);
    HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable, this);

    OverlayItem overlayitem = new OverlayItem(point, "", "");
    itemizedoverlay.addOverlay(overlayitem);
    mapView.getOverlays().add(itemizedoverlay);

    mapView.getController().animateTo(point);
    mapView.getController().setZoom(18);
  }