/** Save map's zoom level and centre. You should not need to touch this method */
  @Override
  public void onSaveInstanceState(Bundle outState) {
    Log.d(LOG_TAG, "onSaveInstanceState");
    super.onSaveInstanceState(outState);

    if (mapView != null) {
      outState.putInt("zoomLevel", mapView.getZoomLevel());
      IGeoPoint cntr = mapView.getMapCenter();
      outState.putInt("latE6", cntr.getLatitudeE6());
      outState.putInt("lonE6", cntr.getLongitudeE6());
      Log.i("MapSave", "Zoom: " + mapView.getZoomLevel());
    }
  }
  @Override
  public void onSaveInstanceState(Bundle outState) {
    outState.putParcelable(STATE_MAP_POSITION, (Parcelable) mMapView.getMapCenter());
    outState.putInt(STATE_MAP_ZOOM_LEVEL, mMapView.getZoomLevel());
    outState.putDouble(STATE_INDOOR_LEVEL, mIndoorLevel);

    super.onSaveInstanceState(outState);
  }
Beispiel #3
0
  @Override
  protected void draw(Canvas canvas, MapView mapView, boolean shadow) {
    if (shadow) {
      return;
    }
    MapView.Projection p = mapView.getProjection();

    int idx = 0;
    int geoTrackSize = geoTracks.size();
    boolean isFirstDraw = false;
    for (GeoTrack geoTrack : geoTracks) {
      idx++;
      // Log.d(TAG, "User selected new date range: MIN=" + (geoTrack.time
      // >= seletedRangeBeginTimeInMs) + "ms, MAX=" + (geoTrack.time <=
      // seletedRangeEndTimeInMs)+ ", geoTrack.time="+geoTrack.time);

      if (!seletedRangeActivated
          || (geoTrack.time >= seletedRangeBeginTimeInMs
              && geoTrack.time <= seletedRangeEndTimeInMs)) {
        GeoPoint geoPoint = geoTrack.asGeoPoint();
        p.toMapPixels(geoPoint, myScreenCoords);
        // Line Path
        boolean isLast = geoTrackSize == idx;
        if (isFirstDraw) {
          canvas.drawLine(
              lastScreenCoords.x, lastScreenCoords.y, myScreenCoords.x, myScreenCoords.y, mPaint);
        }
        // Point
        canvas.drawCircle(myScreenCoords.x, myScreenCoords.y, 4, mGeoPointPaint);
        if (isLast) {
          canvas.drawCircle(
              myScreenCoords.x, myScreenCoords.y, 8, mGeoPointAccuracyCirclePaintBorder);
          canvas.drawCircle(
              myScreenCoords.x, myScreenCoords.y, 12, mGeoPointAccuracyCirclePaintBorder);
        }
        // End Loop
        lastScreenCoords.x = myScreenCoords.x;
        lastScreenCoords.y = myScreenCoords.y;
        isFirstDraw = true;
      }
    }

    // Draw Selected
    if (selectedGeoTrack != null) {
      // Select Point
      GeoTrack lastFix = selectedGeoTrack;
      GeoPoint geoPoint = lastFix.asGeoPoint();
      p.toMapPixels(geoPoint, myScreenCoords);
      // Compute Radius Accuracy
      final float groundResolutionInM =
          lastFix.computeGroundResolutionInMForZoomLevel(mapView.getZoomLevel());
      final float radius = ((float) lastFix.getAccuracy()) / groundResolutionInM;
      canvas.drawCircle(myScreenCoords.x, myScreenCoords.y, radius, mGeoPointAccuracyCirclePaint);
      canvas.drawCircle(
          myScreenCoords.x, myScreenCoords.y, radius, mGeoPointAccuracyCirclePaintBorder);
    }
  }
  /**
   * Populates this bubble with all item info:
   *
   * <ul>
   *   title and description in any case,
   * </ul>
   *
   * <ul>
   *   image and sub-description if any.
   * </ul>
   *
   * and centers the map on the item. <br>
   */
  public void showBubble(ExtendedOverlayItem item, InfoWindow bubble, MapView mapView) {
    Log.d(TAG, "showBubble");
    // offset the bubble to be top-centered on the marker:
    Drawable marker = getMarker(mapView.getZoomLevel());
    int markerWidth = marker.getIntrinsicWidth();
    int markerHeight = marker.getIntrinsicHeight();

    Point markerH = item.getHotspot(HotspotPlace.BOTTOM_CENTER, markerWidth, markerHeight);
    Point bubbleH = item.getHotspot(HotspotPlace.BOTTOM_CENTER, markerWidth, markerHeight);
    bubbleH.offset(-markerH.x, -markerH.y - markerHeight);
    bubble.open(item, bubbleH.x, bubbleH.y);

    mapView.getController().animateTo(item.getPoint());
  }
Beispiel #5
0
  @Override
  public void draw(final Canvas c, final MapView mapView, final boolean shadow) {

    if (shadow) {
      return;
    }

    // If map views is animating, don't update, scale will be wrong.
    if (mapView.isAnimating()) {
      return;
    }

    final int zoomLevel = mapView.getZoomLevel();

    if (zoomLevel >= minZoom) {
      final Projection projection = mapView.getProjection();

      if (projection == null) {
        return;
      }

      final IGeoPoint center = projection.fromPixels((screenWidth / 2), screenHeight / 2);
      if (zoomLevel != lastZoomLevel
          || (int) (center.getLatitudeE6() / 1E6) != (int) (lastLatitude / 1E6)) {
        lastZoomLevel = zoomLevel;
        lastLatitude = center.getLatitudeE6();
        createScaleBarPicture(mapView);
      }

      mBounds.set(projection.getScreenRect());
      mBounds.offset((int) xOffset, (int) yOffset);

      mBounds.set(
          mBounds.left,
          mBounds.top,
          mBounds.left + scaleBarPicture.getWidth(),
          mBounds.top + scaleBarPicture.getHeight());
      c.drawPicture(scaleBarPicture, mBounds);
    }
  }
  @Override
  public void draw(final Canvas canvas, final MapView mapView, final boolean shadow) {
    if (shadow) {
      return;
    }

    final int zoomLevel = mapView.getZoomLevel();
    final Projection projection = mapView.getProjection();
    final int size = this.mItemList.size() - 1;

    /* Draw in backward cycle, so the items with the least index are on the front. */
    for (int i = size; i >= 0; i--) {
      final Item item = getItem(i);
      projection.toPixels(item.getPoint(), mCurScreenCoords);

      if (item != mItemWithBubble) {
        onDrawItem(canvas, zoomLevel, item, mCurScreenCoords);
      }
    }

    onDrawFocusBubble(canvas, zoomLevel, projection);
  }
Beispiel #7
0
  private GeoTrack getHitMapLocation(MapView mapView, IGeoPoint tapPoint) {
    // Track which MapLocation was hit...if any
    GeoTrack result = null;
    RectF tapPointHitTestRect = new RectF();
    Point tapPointTestScreenCoords = new Point();
    int zoonLevel = mapView.getZoomLevel();
    int selectRadius = zoonLevel + 6;
    Projection pj = mapView.getProjection();
    for (GeoTrack testLocation : geoTracks) {
      if (!seletedRangeActivated
          || (testLocation.time >= seletedRangeBeginTimeInMs
              && testLocation.time <= seletedRangeEndTimeInMs)) {
        // Translate the MapLocation's lat/long coordinates to screen
        // coordinates
        pj.toPixels(testLocation.asGeoPoint(), tapPointTestScreenCoords);

        // Create a 'hit' testing Rectangle w/size and coordinates of
        // our
        // icon
        // Set the 'hit' testing Rectangle with the size and coordinates
        // of
        // our on screen icon
        tapPointHitTestRect.set(-selectRadius, -selectRadius, selectRadius, selectRadius);
        tapPointHitTestRect.offset(tapPointTestScreenCoords.x, tapPointTestScreenCoords.y);

        // Finally test for a match between our 'hit' Rectangle and the
        // location clicked by the user
        pj.toPixels(tapPoint, tapPointTestScreenCoords);
        if (tapPointHitTestRect.contains(tapPointTestScreenCoords.x, tapPointTestScreenCoords.y)) {
          result = testLocation;
          // break;
        }
      }
    }
    return result;
  }
 /** @see com.brantapps.polaris.api.Mappable#getZoomLevel() */
 @Override
 public float getZoomLevel() {
   return mapView.getZoomLevel();
 }