private void showOnMap(LatLon latLon, boolean updateCoords, boolean ignoreCoef) {
    AnimateDraggingMapThread thread = map.getAnimatedDraggingThread();
    int fZoom = map.getZoom();
    double flat = latLon.getLatitude();
    double flon = latLon.getLongitude();

    RotatedTileBox cp = map.getCurrentRotatedTileBox().copy();
    if (ignoreCoef) {
      cp.setCenterLocation(0.5f, 0.5f);
    } else {
      cp.setCenterLocation(
          0.5f, map.getMapPosition() == OsmandSettings.BOTTOM_CONSTANT ? 0.15f : 0.5f);
    }
    cp.setLatLonCenter(flat, flon);
    flat = cp.getLatFromPixel(cp.getPixWidth() / 2, cp.getPixHeight() / 2);
    flon = cp.getLonFromPixel(cp.getPixWidth() / 2, cp.getPixHeight() / 2);

    if (updateCoords) {
      mapCenter = new LatLon(flat, flon);
      menu.setMapCenter(mapCenter);
      origMarkerX = cp.getCenterPixelX();
      origMarkerY = cp.getCenterPixelY();
    }

    thread.startMoving(flat, flon, fZoom, true);
  }
Пример #2
0
  private LatLon getAdjustedMarkerLocation(
      int y, LatLon reqMarkerLocation, boolean center, int zoom) {
    double markerLat = reqMarkerLocation.getLatitude();
    double markerLon = reqMarkerLocation.getLongitude();
    RotatedTileBox box = getBox();
    // box.setCenterLocation(0.5f, map.getMapPosition() == OsmandSettings.BOTTOM_CONSTANT ? 0.15f :
    // 0.5f);
    box.setZoom(zoom);
    int markerMapCenterX =
        (int) box.getPixXFromLatLon(mapCenter.getLatitude(), mapCenter.getLongitude());
    int markerMapCenterY =
        (int) box.getPixYFromLatLon(mapCenter.getLatitude(), mapCenter.getLongitude());
    float cpyOrig = box.getCenterPixelPoint().y;

    box.setCenterLocation(0.5f, 0.5f);
    int markerX = (int) box.getPixXFromLatLon(markerLat, markerLon);
    int markerY = (int) box.getPixYFromLatLon(markerLat, markerLon);
    QuadPoint cp = box.getCenterPixelPoint();
    float cpx = cp.x;
    float cpy = cp.y;

    float cpyDelta = menu.isLandscapeLayout() ? 0 : cpyOrig - cpy;

    markerY += cpyDelta;
    y += cpyDelta;
    float origMarkerY = this.origMarkerY + cpyDelta;

    LatLon latlon;
    if (center) {
      latlon = reqMarkerLocation;
    } else {
      latlon = box.getLatLonFromPixel(markerMapCenterX, markerMapCenterY);
    }
    if (menu.isLandscapeLayout()) {
      int x = menu.getLandscapeWidthPx();
      if (markerX - markerPaddingXPx < x || markerX > origMarkerX) {
        int dx = (x + markerPaddingXPx) - markerX;
        int dy = 0;
        if (center) {
          dy = (int) cpy - markerY;
        } else {
          cpy = cpyOrig;
        }
        if (dx >= 0 || center) {
          latlon = box.getLatLonFromPixel(cpx - dx, cpy - dy);
        }
      }
    } else {
      if (markerY + markerPaddingPx > y || markerY < origMarkerY) {
        int dx = 0;
        int dy = markerY - (y - markerPaddingPx);
        if (markerY - dy <= origMarkerY) {
          if (center) {
            dx = markerX - (int) cpx;
          }
          latlon = box.getLatLonFromPixel(cpx + dx, cpy + dy);
        }
      }
    }
    return latlon;
  }