/** Zoom out on the map, but not past level 10 */
 private void zoomOut() {
   int zoom = mvMap.getZoomLevel() - 1;
   if (zoom < 5) {
     zoom = 5;
   }
   mvMap.getController().setZoom(zoom);
 }
示例#2
0
    public void draw(android.graphics.Canvas canvas, MapView mapView, boolean shadow) {
      super.draw(canvas, mapView, false);

      // Disable unzooming map more than level 14, there will be to many
      // stations in map view
      if (mapView.getZoomLevel() < 14) mapView.getController().setZoom(14);
    }
 /**
  * If a segment contains more then 500 waypoints and is zoomed out more then twice then some
  * waypoints will not be used to render the line, this speeding things along.
  */
 private void calculateStepSize() {
   Cursor waypointsCursor = null;
   if (mRequeryFlag || mStepSize < 1 || mWaypointCount < 0) {
     try {
       waypointsCursor =
           this.mResolver.query(
               this.mWaypointsUri, new String[] {Waypoints._ID}, null, null, null);
       mWaypointCount = waypointsCursor.getCount();
     } finally {
       if (waypointsCursor != null) {
         waypointsCursor.close();
       }
     }
   }
   if (mWaypointCount < 250) {
     mStepSize = 1;
   } else {
     int zoomLevel = mMapView.getZoomLevel();
     int maxZoomLevel = mMapView.getMaxZoomLevel();
     if (zoomLevel >= maxZoomLevel - 2) {
       mStepSize = 1;
     } else {
       mStepSize = maxZoomLevel - zoomLevel;
     }
   }
 }
 @Override
 public void draw(Canvas canvas, MapView mapView, boolean shadow) {
   if (longPressFinished) {
     longPressFinished = false;
     this.gs.invokeLongPressFinished();
   }
   if (zoomFinished) {
     zoomFinished = false;
     this.gs.invokeZoomFinished();
   }
   super.draw(canvas, mapView, false);
   if (lastZoomlevel == -1) lastZoomlevel = mapView.getZoomLevel();
   if (mapView.getZoomLevel() != lastZoomlevel) {
     this.gs.invokeZoomEvent(lastZoomlevel, mapView.getZoomLevel());
     lastZoomlevel = mapView.getZoomLevel();
   }
 }
示例#5
0
 private void setStepSize() {
   int zoomLevel = mMapView.getZoomLevel();
   int maxZoomLevel = mMapView.getMaxZoomLevel();
   if (mMapView != null && zoomLevel >= maxZoomLevel - 1) {
     stepSize = 1;
   } else {
     stepSize = (maxZoomLevel - zoomLevel) * 2;
   }
   //      Log.d( TAG, "Setting stepSize "+stepSize+" on a zoom of "+zoomLevel+"/"+maxZoomLevel );
 }
示例#6
0
    @Override
    public void draw(Canvas canvas, MapView mapView, boolean shadow) {
      super.draw(canvas, mapView, shadow);

      int zoom = mapView.getZoomLevel();
      if (zoom <= 10) {
        LINE_WIDTH = 1;
      } else if (zoom < 15) {
        LINE_WIDTH = 2;
      } else {
        LINE_WIDTH = 3;
      }
      initPaint();

      try {
        boundCenterBottom(marker);
        if (listRoutePoint != null) {
          Projection projection = mapView.getProjection();
          canvas.drawPath(getPath(convertListGeoPointToPoint(listRoutePoint, projection)), paint);
        }
      } catch (Throwable e) {
      }
    }
 /** Zoom in on the map */
 private void zoomIn() {
   mvMap.getController().setZoom(mvMap.getZoomLevel() + 1);
 }
 @Override
 public int getZoomLevel() {
   return mMapView.getZoomLevel();
 }
示例#9
0
  public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    TextView tv = (TextView) v;
    String address = tv.getText().toString();

    String[] aux = address.split(" ");
    address = new String();
    for (int i = 0; i < aux.length - 1; ++i) {
      if (i == 0) address = aux[i];
      else address = address + " " + aux[i];
    }

    SQLiteDatabase myDB = null;

    myDB = openOrCreateDatabase(DB_NAME, 1, null);

    myDB.execSQL(
        "CREATE TABLE IF NOT EXISTS "
            + TABLE
            + " ("
            + ADDR_DB
            + " TEXT NOT NULL PRIMARY KEY, "
            + COORD_X_DB
            + " INTEGER NOT NULL, "
            + COORD_Y_DB
            + " INTEGER NOT NULL, "
            + INF_DB
            + " TEXT, "
            + DAY_DB
            + " INTEGER, "
            + MONTH_DB
            + " INTEGER, "
            + YEAR_DB
            + " INTEGER);");

    String[] FROM = {COORD_X_DB, COORD_Y_DB};
    String WHERE = ADDR_DB + " = '" + address + "'";

    Cursor c = myDB.query(TABLE, FROM, WHERE, null, null, null, null);

    startManagingCursor(c);

    GeoPoint point = null;
    if (c.moveToNext()) {
      point = new GeoPoint(c.getInt(0), c.getInt(1));
    }

    c.close();
    if (myDB != null) myDB.close();

    tabHost.setCurrentTabByTag("Mapa");

    if (point != null) {
      controller.animateTo(point);
    }
    while (map.getZoomLevel() != 14) {
      if (map.getZoomLevel() < 14) {
        controller.zoomIn();
      } else if (map.getZoomLevel() > 14) {
        controller.zoomOut();
      }
    }
  }