public OwnPositionOverlay(WayfinderMapView ownerMap) {
    iOwnerMap = ownerMap;
    this.application = (NavigatorApplication) this.iOwnerMap.getContext().getApplicationContext();

    this.radiusPaint = new Paint();
    this.radiusPaint.setAntiAlias(true);
    this.borderPaint = new Paint();
    this.borderPaint.setStrokeWidth(1);
    this.borderPaint.setAntiAlias(true);
    this.borderPaint.setStyle(Style.STROKE);
    this.textSize =
        this.application
            .getResources()
            .getDimensionPixelSize(R.dimen.distance_to_myposition_text_size);
    this.borderPaint.setTextSize(this.textSize);

    Resources resources = iOwnerMap.getContext().getResources();
    ownPositionPinEnabled1 = BitmapFactory.decodeResource(resources, R.drawable.position_1);
    ownPositionPinEnabled2 = BitmapFactory.decodeResource(resources, R.drawable.position_2);
    ownPositionPinDisabled = BitmapFactory.decodeResource(resources, R.drawable.position_disabled);
    arrow = BitmapFactory.decodeResource(resources, R.drawable.arrow);
  }
  public void draw(
      Canvas canvas, MapCameraInterface mapCamera, MapRenderer mapRenderer, View mapOverlay) {
    if (canvas == null) {
      return;
    }

    LocationInformation ownLocation = this.application.getOwnLocationInformation();
    LocationProvider provider = this.application.getLocationProvider();

    int[] ownPositionCoords =
        mapCamera.getScreenCoordinate(
            (int) ownLocation.getMC2Position().getMc2Latitude(),
            (int) ownLocation.getMC2Position().getMc2Longitude());
    if (provider != null) {
      int origX = ownPositionCoords[0];
      int origY = ownPositionCoords[1];
      int x = origX;
      int y = origY;

      boolean isOnScreen = true;
      int arrowSize = this.arrow.getWidth() >> 1;

      int coords[] = {0, 0};
      if (mapOverlay != null) {
        mapOverlay.getLocationOnScreen(coords);
      }
      int top = coords[1];

      iOwnerMap.getLocationOnScreen(coords);
      top -= coords[1];

      int canvasHeight = canvas.getHeight();
      this.overlayHeight = (mapOverlay != null ? canvasHeight - top : 0);
      this.minX = arrowSize;
      this.maxX = canvas.getWidth() - arrowSize;
      this.minY = arrowSize;
      this.maxY = canvasHeight - this.overlayHeight - arrowSize;

      if (x < this.minX) {
        x = this.minX;
        isOnScreen = false;
      }

      if (x > this.maxX) {
        x = this.maxX;
        isOnScreen = false;
      }

      if (y < this.minY) {
        y = this.minY;
        isOnScreen = false;
      }

      if (y > this.maxY) {
        y = this.maxY;
        isOnScreen = false;
      }

      draw(canvas, mapCamera, ownLocation, provider, origX, origY, x, y, isOnScreen);
    }
  }