Esempio n. 1
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
      case R.id.Sat_View:
        mapView.setSatellite(true);
        mapView.setStreetView(true);
        return true;

      case R.id.Map_View:
        mapView.setSatellite(false);
        mapView.setStreetView(false);
        return true;

      case R.id.Map_Menu_All:
        startActivity(new Intent(this, Maps.class));
        Toast.makeText(this, R.string.toast_all, Toast.LENGTH_LONG).show();
        this.finish();
        return true;

      case R.id.Map_Menu_Free:
        startActivity(new Intent(this, MapsFree.class));
        Toast.makeText(this, R.string.toast_free, Toast.LENGTH_LONG).show();
        this.finish();
        return true;

      case R.id.Map_Menu_Art:
        startActivity(new Intent(this, MapsArt.class));
        Toast.makeText(this, R.string.toast_art, Toast.LENGTH_LONG).show();
        this.finish();
        return true;

      case R.id.Map_Menu_Mansion:
        startActivity(new Intent(this, MapsMansion.class));
        Toast.makeText(this, R.string.toast_mansion, Toast.LENGTH_LONG).show();
        this.finish();
        return true;

      case R.id.Map_Menu_History:
        startActivity(new Intent(this, MapsHistory.class));
        Toast.makeText(this, R.string.toast_history, Toast.LENGTH_LONG).show();
        this.finish();
        return true;

      case R.id.Map_Menu_Science:
        startActivity(new Intent(this, MapsScience.class));
        Toast.makeText(this, R.string.toast_science, Toast.LENGTH_LONG).show();
        this.finish();
        return true;

      default:
        return super.onOptionsItemSelected(item);
    }
  }
 /** @see android.app.Activity#onOptionsItemSelected(android.view.MenuItem) */
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case 0:
       // Zoom in
       zoomIn();
       return true;
     case 1:
       // Zoom out
       zoomOut();
       return true;
     case 2:
       // Toggle satellite views
       mvMap.setSatellite(!mvMap.isSatellite());
       return true;
     case 3:
       // Toggle street views
       mvMap.setStreetView(!mvMap.isStreetView());
       return true;
     case 4:
       // Toggle traffic views
       mvMap.setTraffic(!mvMap.isTraffic());
       return true;
     case 5:
       // Show the job list activity
       startActivity(new Intent(MicroJobs.this, MicroJobsList.class));
       return true;
   }
   return false;
 }
Esempio n. 3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tabs);

    // Adding the zoom option
    mapView = (MapView) findViewById(R.id.MapView);
    LinearLayout zoomLayout = (LinearLayout) findViewById(R.id.zoom);
    View zoomView = mapView;

    zoomLayout.addView(
        zoomView,
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    mapView.displayZoomControls(true);

    mc = mapView.getController();
    String coordinates[] = {"32.2217429", " -110.926479"};
    double lat = Double.parseDouble(coordinates[0]);
    double lng = Double.parseDouble(coordinates[1]);

    p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6));

    mc.animateTo(p);
    mc.setZoom(10);
    mapView.invalidate();
    mapView.setSatellite(false);
    mapView.setStreetView(false);
    // bTakePicture = (Button)findViewById(R.id.bTakePicture);
    // bTakePicture.setOnClickListener(this);
  }
Esempio n. 4
0
  private void init() {

    this.lblTitulo = (TextView) this.findViewById(R.id.mapa_titulo);

    final MapView mapa = (MapView) this.findViewById(R.id.mapa);
    mapa.setStreetView(true);

    final Intent intent = this.getIntent();
    if (intent != null) {

      final Object anuncio = intent.getSerializableExtra(ANUNCIO);
      if (anuncio != null) {

        this.anuncio = (Anuncio) anuncio;

        this.lblTitulo.setText(
            this.anuncio.getProduto().getNome() + " (" + this.anuncio.getValorFormatado() + ")");

        final GeoPoint ponto = new Ponto(this.anuncio.getLatitude(), this.anuncio.getLongitude());
        mapa.getOverlays().add(new PontoOverlay(ponto, R.drawable.guaraba_wally_30));
        mapa.getController().setZoom(18);
        mapa.getController().setCenter(ponto);
      }
    }
  }
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   Log.d("Test", "I already reach there");
   setContentView(R.layout.main);
   // launchGPSOptions();
   mapView = (MapView) findViewById(R.id.myMap);
   LinearLayout zoomLayout = (LinearLayout) findViewById(R.id.zoom);
   View zoomView = mapView.getZoomControls();
   mapView.displayZoomControls(true);
   mapView.setStreetView(true);
   mapController = mapView.getController();
   mapController.setZoom(14);
   mapView.setOnTouchListener(
       new OnTouchListener() {
         @Override
         public boolean onTouch(View arg0, MotionEvent arg1) {
           return onTouchEvent((MapView) arg0, arg1);
         }
       });
   listOfOverlays = mapView.getOverlays();
   zoomLayout.addView(
       zoomView,
       new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
   final TelephonyManager tm =
       (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
   final String tmDevice, tmSerial, androidId;
   tmDevice = "" + tm.getDeviceId();
   tmSerial = "" + tm.getSimSerialNumber();
   androidId =
       ""
           + android.provider.Settings.Secure.getString(
               getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
   UUID deviceUuid =
       new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
   uuid = deviceUuid.toString();
   logging("UUID " + uuid);
   preSetting = getSharedPreferences(PREFERENCE_NAME, MODE_PRIVATE);
   startService(new Intent(AlertService.class.getName()));
   locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
   locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 100, 10f, this);
   locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 100, 10f, this);
   displayLocationTask = new DisplayLocationTask();
   timer = new Timer("UpdateOtherLocationTimer");
   checkLocationAndAction();
 }
Esempio n. 6
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mapa = (MapView) findViewById(R.id.mapaView);

    // Instancia do controlador do mapa
    controlador = mapa.getController();

    // Instancia ums imagem (overlay) que representar� o usuario no mapa
    LocalUserOverlay imagem = new LocalUserOverlay(new PontoIzabel(), R.drawable.red_ball);
    mapa.getOverlays().add(imagem);

    // centraliza o mapa em uma determinada coordenada
    controlador.animateTo(new PontoIzabel());

    // Centraliza o mapa na ultima localizacao conhecida
    LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
    /* Location local = getLocationManager().getLastKnownLocation(LocationManager.GPS_PROVIDER);

    if(local != null){   //Se existe ultima localizacao converte para GeoPoint

    	Ponto ponto = new Ponto(local);minTime
    	//Instancia ums imagem (overlay) que representar� o usuario no mapa
    	 imagem = new LocalUserOverlay (ponto, R.drawable.red_ball);
         mapa.getOverlays().add(imagem);
    	controlador.setCenter(ponto);
    }else{
    	getMensage("Aviso", "N�o foi possiver rastrear nova localiza��o");
    }

    //GPS Listener
    getLocationManager().requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);*/

    mapa.setStreetView(true); // configura pra mostrar o mapa no modo street
    mapa.setClickable(true);
    // define o zoom do mapa
    controlador.setZoom(19);
    mapa.setBuiltInZoomControls(true);
  }
Esempio n. 7
0
  private void updateMapView() {
    int intZoomLevel = 17;
    MapView mapView = (MapView) findViewById(0 /*R.id.map*/);
    mapController = mapView.getController();
    mapView.setSatellite(false);
    mapView.setStreetView(true);
    mapView.setTraffic(true);

    geoPoint = new GeoPoint((int) (dLat), (int) (dLng /* * 1E6*/)); // 將剛剛取得的座標置入geoPoint
    mapView.displayZoomControls(true);
    mapView.setBuiltInZoomControls(true);

    mapController.animateTo(geoPoint); // 將map的中心點移到自己所在的位置
    mapController.setZoom(intZoomLevel); // 設定地圖級距

    // 加入地圖標籤
    MyLocationOverlay mapOverlay = new MyLocationOverlay(context, mapView);
    List listOfOverlays = mapView.getOverlays();
    listOfOverlays.clear();
    listOfOverlays.add(mapOverlay);
  }
  /**
   * Called when the activity is first created.
   *
   * @see com.google.android.maps.MapActivity#onCreate(android.os.Bundle)
   */
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    // start trace
    // Debug.startMethodTracing("x");
    Debug.startMethodTracing("/data/data/com.microjobsinc.mjandroid/x.trace");
    setContentView(R.layout.main);

    db = new MicroJobsDatabase(this);

    // Get current position
    // The LocationManager is a special class that
    // Android instantiates for you, and you can retrieve the
    // instance for your application through the call to
    // getSystemService.
    final Location myLocation =
        getCurrentLocation((LocationManager) getSystemService(Context.LOCATION_SERVICE));

    Spinner spnLocations = (Spinner) findViewById(R.id.spnLocations);

    // Connect the Java MapView to the attributes defined for it in
    // main.xml, and
    mvMap = (MapView) findViewById(R.id.mapmain);
    // Get the map controller
    final MapController mc = mvMap.getController();
    // Create a LocationOverlay that will build and draw the Map in our
    // MapView when we want to view a map of our local area.
    mMyLocationOverlay = new MyLocationOverlay(this, mvMap);
    mMyLocationOverlay.enableMyLocation();
    // The first thing we do with mMyLocationOverlay is define
    // a method that Android will call when we receive our first
    // location fix from the location provider
    mMyLocationOverlay.runOnFirstFix(
        new Runnable() {
          public void run() {
            // move the map to the current location (given by
            // mMyLocationOverlay.getMyLocation()
            mc.animateTo(mMyLocationOverlay.getMyLocation());
            mc.setZoom(16);
          }
        });
    // Identify a marker to use on mMyLocationOverlay to mark
    // available jobs
    Drawable marker = getResources().getDrawable(R.drawable.android_tiny_image);
    marker.setBounds(0, 0, marker.getIntrinsicWidth(), marker.getIntrinsicHeight());
    // add the marker overlay to the list of overlays for the MapView mvMap.
    mvMap.getOverlays().add(new MJJobsOverlay(marker));
    // set some initial attributes for mvMap
    // We want users to be able to click(tap) on
    // a job to display more detail about this job
    mvMap.setClickable(true);
    // This method is inherited from android.view.View
    // it enables the standard map functions(zooming, panning)
    mvMap.setEnabled(true);
    // Setting this flag adds a satellite view
    mvMap.setSatellite(false);
    mvMap.setTraffic(false);
    mvMap.setStreetView(false);

    // start out with a general zoom
    mc.setZoom(16);
    mvMap.invalidate();

    // Create a button click listener for the List Jobs button.
    Button btnList = (Button) findViewById(R.id.btnShowList);
    btnList.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View v) {
            Intent intent = new Intent(MicroJobs.this.getApplication(), MicroJobsList.class);
            startActivity(intent);
          }
        });

    // A list of favorite locations that the Spinner will
    // display and the user can select
    List<String> lsLocations = new ArrayList<String>();
    // Load a HashMap with locations and positions
    final HashMap<String, GeoPoint> hmLocations = new HashMap<String, GeoPoint>();
    hmLocations.put("Current Location", new GeoPoint(latitude, longitude));
    lsLocations.add("Current Location");

    // Add favorite locations from this user's record in workers table
    worker = db.getWorker();
    hmLocations.put(
        worker.getColLoc1Name(),
        new GeoPoint((int) worker.getColLoc1Lat(), (int) worker.getColLoc1Long()));
    lsLocations.add(worker.getColLoc1Name());
    hmLocations.put(
        worker.getColLoc2Name(),
        new GeoPoint((int) worker.getColLoc2Lat(), (int) worker.getColLoc2Long()));
    lsLocations.add(worker.getColLoc2Name());
    hmLocations.put(
        worker.getColLoc3Name(),
        new GeoPoint((int) worker.getColLoc3Lat(), (int) worker.getColLoc3Long()));
    lsLocations.add(worker.getColLoc3Name());
    // Spinner views require an ArrayAdapter to feed them the list,
    // attaching the list of locations to the ArrayAdapter
    ArrayAdapter<String> aspnLocations =
        new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, lsLocations);
    // Provide the Spinner with the drop-down layout necessary for the user
    // to display the whole list of locations.
    aspnLocations.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spnLocations.setAdapter(aspnLocations);

    // Setup a callback for the spinner
    spnLocations.setOnItemSelectedListener(
        new OnItemSelectedListener() {
          public void onNothingSelected(AdapterView<?> arg0) {}
          // Enables the appropriate action when the user clicks on an item
          public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
            TextView vt = (TextView) v;
            if ("Current Location".equals(vt.getText())) {
              mMyLocationOverlay.enableMyLocation();
              try {
                mc.animateTo(mMyLocationOverlay.getMyLocation());
              } catch (Exception e) {
                Log.i("MicroJobs", "Unable to animate map", e);
              }
              mvMap.invalidate();
            } else {
              mMyLocationOverlay.disableMyLocation();
              mc.animateTo(hmLocations.get(vt.getText()));
            }
            mvMap.invalidate();
          }
        });
  }