예제 #1
0
 @Override
 public void onDestroyView() {
   super.onDestroyView();
   if (mapCenter != null) {
     PointI centerI =
         Utilities.convertLatLonTo31(
             new net.osmand.core.jni.LatLon(mapCenter.getLatitude(), mapCenter.getLongitude()));
     getMainActivity().setTarget(centerI);
   }
   menu.setMapCenter(null);
   menu.setMapZoom(0);
 }
예제 #2
0
 public void setFragmentVisibility(boolean visible) {
   if (visible) {
     view.setVisibility(View.VISIBLE);
     if (mapCenter != null) {
       PointI targetI =
           Utilities.convertLatLonTo31(
               new net.osmand.core.jni.LatLon(mapCenter.getLatitude(), mapCenter.getLongitude()));
       getMainActivity().setTarget(targetI);
     }
     adjustMapPosition(getPosY(), true, false);
   } else {
     view.setVisibility(View.GONE);
   }
 }
예제 #3
0
  private void adjustMapPosition(int y, boolean animated, boolean center) {
    // map.getAnimatedDraggingThread().stopAnimatingSync(); todo animation
    LatLon latlon = getAdjustedMarkerLocation(y, menu.getLatLon(), center, getZoom());

    LatLon mapLatLon = getMainActivity().getScreenCenter();
    if (mapLatLon.getLatitude() == latlon.getLatitude()
        && mapLatLon.getLongitude() == latlon.getLongitude()) {
      return;
    }

    if (animated) {
      showOnMap(latlon, false, true, true);
    } else {
      PointI targetI =
          Utilities.convertLatLonTo31(
              new net.osmand.core.jni.LatLon(latlon.getLatitude(), latlon.getLongitude()));
      getMainActivity().setTarget(targetI);
    }
  }
예제 #4
0
  private void showOnMap(
      LatLon latLon, boolean updateCoords, boolean needMove, boolean alreadyAdjusted) {
    // AnimateDraggingMapThread thread = map.getAnimatedDraggingThread(); todo amimation
    int fZoom = getZoom();
    double flat = latLon.getLatitude();
    double flon = latLon.getLongitude();

    RotatedTileBox cp = getBox();
    // cp.setCenterLocation(0.5f, map.getMapPosition() == OsmandSettings.BOTTOM_CONSTANT ? 0.15f :
    // 0.5f);
    cp.setLatLonCenter(flat, flon);
    cp.setZoom(fZoom);
    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();
    }

    if (!alreadyAdjusted) {
      LatLon adjustedLatLon =
          getAdjustedMarkerLocation(getPosY(), new LatLon(flat, flon), true, fZoom);
      flat = adjustedLatLon.getLatitude();
      flon = adjustedLatLon.getLongitude();
    }

    if (needMove) {
      // thread.startMoving(flat, flon, fZoom, true); todo animation
      PointI targetI = Utilities.convertLatLonTo31(new net.osmand.core.jni.LatLon(flat, flon));
      getMainActivity().setTarget(targetI);
      getMainActivity().setZoom(fZoom);
    }
  }