@Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (this.getIntent().getExtras() != null && this.getIntent().getExtras().get("route") != null) {
      selectedRoute = (Route) this.getIntent().getExtras().get("route");
    }

    if (this.getIntent().getExtras() != null && this.getIntent().getExtras().get("stop") != null) {
      selectedStop = (Stop) this.getIntent().getExtras().get("stop");
    }

    status = (TextView) findViewById(R.id.status);
  }
예제 #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // chargement du fichier map
    File map =
        new File(
            Environment.getExternalStorageDirectory().toString() + "/Arboretum/Map/grenoble.map");
    // ajout de la map proprement
    mapView = new MapView(this);
    mapView.setMapFile(map);
    // on rend la map cliquable
    mapView.setClickable(true);
    // on rend la map zoomable
    mapView.setBuiltInZoomControls(true);
    // affichage de la map
    setContentView(mapView);
    // Creation d'un marker, un objet Drawable
    Drawable defaultMarker = getResources().getDrawable(R.drawable.letter_a);
    Drawable location = getResources().getDrawable(R.drawable.location_unoriented);
    // ici on les stock. La deuxieme liste n'est pas MyItemizdOverlay pour
    // la simple raison qu'elle va stocker notre curseur de position
    // dont on ne souhaite pas qu'il y ai de reaction si on tap dessus
    ArrayItemizedOverlay itemizedOverlay = new MyItemizedOverlay(defaultMarker, this);
    ArrayItemizedOverlay itemizedOverlay2 = new ArrayItemizedOverlay(location);
    // create a GeoPoint with the latitude and longitude coordinates
    GeoPoint myPos = new GeoPoint(0, 0);

    // create an OverlayItem with title and description
    item = new OverlayItem(Global.getArbo(), "Arboretum", "Localisation de l'arboretum.");
    item2 = new OverlayItem(myPos, "Moi", "Ma position.");
    item.setMarker(ItemizedOverlay.boundCenter(defaultMarker));
    item2.setMarker(ItemizedOverlay.boundCenter(location));
    // add the OverlayItem to the ArrayItemizedOverlay
    itemizedOverlay.addItem(item);
    itemizedOverlay2.addItem(item2);
    // Le GPS
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1, 0, this);
    sm = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    if (sm.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD) != null) {
      // success! there's a magnetometer
    } else {
      Toast.makeText(this, "Problème d'accelerometer", Toast.LENGTH_LONG).show();
    }
    // add the ArrayItemizedOverlay to the MapView
    mapView.getOverlays().add(itemizedOverlay);
    mapView.getOverlays().add(itemizedOverlay2);
    // je me centre sur moi
    mapView.setCenter(item2.getPoint());
    // puis je zoom *2
    mapView.zoom((byte) 2, 2);
    // Récupère le root layout
    FrameLayout fl =
        (FrameLayout)
            this.getWindow().getDecorView().getRootView().findViewById(android.R.id.content);
    // Crée le bouton
    myButton = new Button(this);
    myButton.setText("Recentrer");
    myButton.setLayoutParams(
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    // Ajoute le bouton au layout
    fl.addView(myButton);
    myButton.setOnClickListener(this);
  }
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
 }