/**
  * 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;
     }
   }
 }
Ejemplo n.º 2
0
  private void initMapView() {
    mapView = (MapView) findViewById(R.id.mapview);
    mapCtrl = mapView.getController();

    final int maxZoomLevel = mapView.getMaxZoomLevel() - zoomCorrection;
    mapCtrl.setZoom(maxZoomLevel);
    mapView.setBuiltInZoomControls(true);
    mapView.setSatellite(true);
  }
Ejemplo n.º 3
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 );
 }
Ejemplo n.º 4
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE); // Suppress title bar to give more space
    setContentView(R.layout.show_the_map);

    initiateLocation();

    // Add map controller with zoom controls
    mapView = (MapView) findViewById(R.id.mv);
    mapView.setSatellite(true);
    mapView.setTraffic(false);
    mapView.setBuiltInZoomControls(true); // Set android:clickable=true in main.xml
    int maxZoom = mapView.getMaxZoomLevel();
    int initZoom = (int) (0.80 * (double) maxZoom);
    mapControl = mapView.getController();
    mapControl.setZoom(initZoom);
    // Convert lat/long in degrees into integers in microdegrees
    latE6 = (int) (lat * 1e6);
    lonE6 = (int) (lon * 1e6);
    gp = new GeoPoint(latE6, lonE6);
    mapControl.animateTo(gp);
  }
  private void setMapCenter(Location location) {

    gc = new Geocoder(this);

    String placename = "";

    try {
      List<Address> place = gc.getFromLocation(location.getLatitude(), location.getLongitude(), 1);
      placename = "Location found: " + place.get(0).getLocality();

    } catch (IOException e) {
      placename =
          String.format("Location found (%s, %s)", location.getLatitude(), location.getLongitude());
    } catch (IndexOutOfBoundsException ioobe) {

    }

    Toast.makeText(this, placename, Toast.LENGTH_SHORT).show();

    Log.d(
        TAG,
        String.format("Location found (%s, %s)", location.getLatitude(), location.getLongitude()));

    controller = myMap.getController();
    zoomMax = myMap.getMaxZoomLevel();
    controller.setCenter(
        new GeoPoint((int) (location.getLatitude() * 1E6), (int) (location.getLongitude() * 1E6)));
    controller.setZoom(zoomMax);

    // put an overlay on the map
    Drawable marker = getResources().getDrawable(R.drawable.sphero_marker);
    int markerWidth = marker.getIntrinsicWidth();
    int markerHeight = marker.getIntrinsicHeight();
    marker.setBounds(0, markerHeight, markerWidth, 0);
    SpheroOverlay spheroOverlay = new SpheroOverlay(marker);
    myMap.getOverlays().add(spheroOverlay);
    spheroOverlay.addItem(locationToGeoPoint(location), "Sphero!", "This is where you're at.");
  }
Ejemplo n.º 6
0
 @Override
 public int getMaxZoomLevel() {
   return mMapView.getMaxZoomLevel();
 }