예제 #1
0
파일: Viewport.java 프로젝트: hjanetzek/vtm
 public Viewport() {
   mPos.scale = mMinScale;
   mPos.x = 0.5;
   mPos.y = 0.5;
   mPos.bearing = 0;
   mPos.tilt = 0;
 }
예제 #2
0
 private MapPosition getUserLocationPosition() {
   GeoPoint point = getUserLocationPoint();
   MapPosition mapPosition =
       new MapPosition(point.getLatitude(), point.getLongitude(), mapController.getZoomScale());
   mapPosition.setBearing(mapController.getMapPosition().getBearing());
   mapPosition.setTilt(mapController.getMapPosition().getTilt());
   return mapPosition;
 }
예제 #3
0
 @Test
 public void findMe_shouldNotResetZoomAndPointNorthAfterMapPositionEvent() throws Exception {
   FragmentTestUtil.startFragment(mapFragment);
   mapFragment.findMe();
   MapPosition mapPosition = new MapPosition();
   mapPosition.setZoomLevel(10);
   activity.getMap().events.fire(Map.POSITION_EVENT, mapPosition);
   mapFragment.findMe();
   assertThat(mapFragment.mapController.getZoomLevel()).isEqualTo(10);
 }
예제 #4
0
파일: Viewport.java 프로젝트: hjanetzek/vtm
  public boolean limitPosition(MapPosition pos) {
    boolean changed = false;
    if (pos.scale > mMaxScale) {
      pos.scale = mMaxScale;
      changed = true;
    } else if (pos.scale < mMinScale) {
      pos.scale = mMinScale;
      changed = true;
    }

    if (pos.tilt > mMaxTilt) {
      pos.tilt = mMaxTilt;
      changed = true;
    } else if (pos.tilt < mMinTilt) {
      pos.tilt = mMinTilt;
      changed = true;
    }

    if (pos.bearing > mMaxBearing) {
      pos.bearing = mMaxBearing;
      changed = true;
    } else if (pos.bearing < mMinBearing) {
      pos.bearing = mMinBearing;
      changed = true;
    }

    if (pos.x > mMaxX) {
      pos.x = mMaxX;
      changed = true;
    } else if (pos.x < mMinX) {
      pos.x = mMinX;
      changed = true;
    }

    if (pos.y > mMaxY) {
      pos.y = mMaxY;
      changed = true;
    } else if (pos.y < mMinY) {
      pos.y = mMinY;
      changed = true;
    }

    return changed;
  }
예제 #5
0
파일: Viewport.java 프로젝트: hjanetzek/vtm
  /**
   * Get the current MapPosition.
   *
   * @param pos MapPosition to be updated.
   * @return true iff current position is different from passed position.
   */
  public boolean getMapPosition(MapPosition pos) {

    boolean changed =
        (pos.scale != mPos.scale
            || pos.x != mPos.x
            || pos.y != mPos.y
            || pos.bearing != mPos.bearing
            || pos.tilt != mPos.tilt);

    pos.bearing = mPos.bearing;
    pos.tilt = mPos.tilt;

    pos.x = mPos.x;
    pos.y = mPos.y;
    pos.scale = mPos.scale;
    pos.zoomLevel = FastMath.log2((int) mPos.scale);

    return changed;
  }