Exemplo n.º 1
0
  @Override
  public void draw(Canvas canvas, MapView mapView, boolean shadow) {

    super.draw(canvas, mapView, shadow);

    Projection projection = mapView.getProjection();

    int latSpan = mapView.getLatitudeSpan();
    int lngSpan = mapView.getLongitudeSpan();
    GeoPoint mapCenter = mapView.getMapCenter();
    int mapLeftGeo = mapCenter.getLongitudeE6() - (lngSpan / 2);
    int mapRightGeo = mapCenter.getLongitudeE6() + (lngSpan / 2);

    int mapTopGeo = mapCenter.getLatitudeE6() - (latSpan / 2);
    int mapBottomGeo = mapCenter.getLatitudeE6() + (latSpan / 2);

    GeoPoint geoPoint = this.getSampleLocation();

    if ((geoPoint.getLatitudeE6() > mapTopGeo && geoPoint.getLatitudeE6() < mapBottomGeo)
        && (geoPoint.getLongitudeE6() > mapLeftGeo && geoPoint.getLongitudeE6() < mapRightGeo)) {
      Point myPoint = new Point();
      projection.toPixels(geoPoint, myPoint);
      Bitmap marker =
          BitmapFactory.decodeResource(mapView.getContext().getResources(), R.drawable.markerblue);
      canvas.drawBitmap(marker, myPoint.x - 15, myPoint.y - 30, null);
    }
  }
  @Override
  protected void drawMyLocation(
      Canvas canvas, MapView mapView, Location lastFix, GeoPoint myLocation, long when) {
    if (!bugged) {
      try {
        super.drawMyLocation(canvas, mapView, lastFix, myLocation, when);
      } catch (Exception e) {
        // we found a buggy phone, draw the location icons ourselves
        bugged = true;
      }
    }

    if (bugged) {
      if (drawable == null) {

        accuracyPaint = new Paint();
        accuracyPaint.setAntiAlias(true);
        accuracyPaint.setStrokeWidth(2.0f);

        drawable =
            mapView
                .getContext()
                .getResources()
                .getDrawable(R.drawable.ic_maps_indicator_current_position);
        width = drawable.getIntrinsicWidth();
        height = drawable.getIntrinsicHeight();
        center = new Point();
        left = new Point();
      }

      Projection projection = mapView.getProjection();
      double latitude = lastFix.getLatitude();
      double longitude = lastFix.getLongitude();
      float accuracy = lastFix.getAccuracy();

      float[] result = new float[1];

      Location.distanceBetween(latitude, longitude, latitude, longitude + 1, result);
      float longitudeLineDistance = result[0];

      GeoPoint leftGeo =
          new GeoPoint(
              (int) (latitude * 1e6), (int) ((longitude - accuracy / longitudeLineDistance) * 1e6));
      projection.toPixels(leftGeo, left);
      projection.toPixels(myLocation, center);
      int radius = center.x - left.x;

      accuracyPaint.setColor(0xff6666ff);
      accuracyPaint.setStyle(Style.STROKE);
      canvas.drawCircle(center.x, center.y, radius, accuracyPaint);

      accuracyPaint.setColor(0x186666ff);
      accuracyPaint.setStyle(Style.FILL);
      canvas.drawCircle(center.x, center.y, radius, accuracyPaint);

      drawable.setBounds(
          center.x - width / 2, center.y - height / 2, center.x + width / 2, center.y + height / 2);
      drawable.draw(canvas);
    }
  }
 public TrafficOverlay(Drawable defaultMarker, MapView mapView, TrafficMap map) {
   super(defaultMarker, mapView);
   // TODO Auto-generated constructor stub
   boundCenterBottom(defaultMarker);
   mContext = mapView.getContext();
   this.map = map;
   populate();
 }
Exemplo n.º 4
0
 public PointerOverlay(Drawable defaultMarker, MapView mapView) {
   super(boundCenter(defaultMarker), mapView);
   c = mapView.getContext();
 }
Exemplo n.º 5
0
 public CustomItemizedOverlay(Drawable defaultMarker, MapView mapView) {
   super(boundCenter(defaultMarker), mapView);
   c = mapView.getContext();
 }
Exemplo n.º 6
0
 // Constructor for the ProfileOverlay class
 public ProfileOverlay(Drawable image, MapView mapView) {
   super(boundCenter(image), mapView);
   populate();
   c = mapView.getContext();
 }