@Override public void onRunAnimation() { final MapView mapview = MapController.this.mOsmv; final IGeoPoint mapCenter = mapview.getMapCenter(); final int stepDuration = this.mStepDuration; try { int newMapCenterLatE6; int newMapCenterLonE6; for (int i = 0; i < this.mSmoothness; i++) { final double delta = Math.pow(0.5, i + 1); final int deltaLatitudeE6 = (int) (this.mPanTotalLatitudeE6 * delta); final int detlaLongitudeE6 = (int) (this.mPanTotalLongitudeE6 * delta); newMapCenterLatE6 = mapCenter.getLatitudeE6() - deltaLatitudeE6; newMapCenterLonE6 = mapCenter.getLongitudeE6() - detlaLongitudeE6; mapview.setMapCenter(newMapCenterLatE6, newMapCenterLonE6); Thread.sleep(stepDuration); } mapview.setMapCenter(super.mTargetLatitudeE6, super.mTargetLongitudeE6); } catch (final Exception e) { this.interrupt(); } }
@Override public void onRunAnimation() { final MapView mapview = MapController.this.mOsmv; final IGeoPoint mapCenter = mapview.getMapCenter(); final int stepDuration = this.mStepDuration; final float amountStretch = this.mAmountStretch; try { int newMapCenterLatE6; int newMapCenterLonE6; for (int i = 0; i < this.mSmoothness; i++) { final double delta = (this.mYOffset + Math.cos(this.mStepIncrement * i + this.mStart)) * amountStretch; final int deltaLatitudeE6 = (int) (this.mPanTotalLatitudeE6 * delta); final int deltaLongitudeE6 = (int) (this.mPanTotalLongitudeE6 * delta); newMapCenterLatE6 = mapCenter.getLatitudeE6() - deltaLatitudeE6; newMapCenterLonE6 = mapCenter.getLongitudeE6() - deltaLongitudeE6; mapview.setMapCenter(newMapCenterLatE6, newMapCenterLonE6); Thread.sleep(stepDuration); } mapview.setMapCenter(super.mTargetLatitudeE6, super.mTargetLongitudeE6); } catch (final Exception e) { this.interrupt(); } }
private boolean onUp(MotionEvent event, MapView mapView) { if (this.onTargetClickListener != null && this.isAClick) { this.clickUpCoords[0] = event.getX(); this.clickUpCoords[1] = event.getY(); if (Math.abs(this.clickUpCoords[0] - this.clickDownCoords[0]) < 10 && Math.abs(this.clickUpCoords[1] - this.clickDownCoords[1]) < 10) { IGeoPoint igeoPoint = mapView.getProjection().fromPixels((int) event.getX(), (int) event.getY()); GeoPoint geoPoint = new GeoPoint(igeoPoint.getLatitudeE6(), igeoPoint.getLongitudeE6()); if (event.getEventTime() - this.clickDownTime < android.view.ViewConfiguration.getLongPressTimeout() && isEventOnTarget(event, mapView)) { this.lockPosition = true; this.onTargetClickListener.onClick(getMyLocation()); return true; } else if (this.lockPosition == false && event.getEventTime() - this.clickDownTime >= 0) { // android.view.ViewConfiguration.getP) { setLocation(geoPoint); mapView.invalidate(); return true; } } this.isAClick = false; } return false; }
private void saveState() { IGeoPoint point = map.getMapCenter(); storage.writeInteger(solidKey + LONGITUDE_SUFFIX, point.getLongitudeE6()); storage.writeInteger(solidKey + LATITUDE_SUFFIX, point.getLatitudeE6()); storage.writeInteger(solidKey + ZOOM_SUFFIX, map.getZoomLevel()); }
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); IGeoPoint point = mOverlay.getGeoPoint(); outState.putInt(MapsConstants.EXTRA_LATITUDE, point.getLatitudeE6()); outState.putInt(MapsConstants.EXTRA_LONGITUDE, point.getLongitudeE6()); }
public static void showActivity(Activity context, SelectedItems selectedItems) { Uri initalUri = null; final Intent intent = new Intent().setClass(context, MapGeoPickerActivity.class); if ((selectedItems != null) && (selectedItems.size() > 0)) { intent.putExtra(EXTRA_SELECTED_ITEMS, selectedItems.toString()); IGeoPoint initialPoint = FotoSql.execGetPosition(context, selectedItems.first().intValue()); if (initialPoint != null) { GeoUri PARSER = new GeoUri(GeoUri.OPT_PARSE_INFER_MISSING); initalUri = Uri.parse( PARSER.toUriString( initialPoint.getLatitude(), initialPoint.getLongitude(), IGeoPointInfo.NO_ZOOM)); intent.setData(initalUri); } GalleryFilterParameter filter = new GalleryFilterParameter(); filter.setNonGeoOnly(true); intent.putExtra(EXTRA_FILTER, filter.toString()); } intent.setAction(Intent.ACTION_VIEW); if (Global.debugEnabled) { Log.d( Global.LOG_CONTEXT, context.getClass().getSimpleName() + " > MapGeoPickerActivity.showActivity@" + initalUri); } context.startActivity(intent); }
/** Set the map views to the given center. There will be no animation. */ @Override public void setCenter(final IGeoPoint point) { final Point p = TileSystem.LatLongToPixelXY( point.getLatitudeE6() / 1E6, point.getLongitudeE6() / 1E6, this.mOsmv.getZoomLevel(), null); final int worldSize_2 = TileSystem.MapSize(this.mOsmv.getZoomLevel()) / 2; this.mOsmv.scrollTo(p.x - worldSize_2, p.y - worldSize_2); }
/** 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()); } }
public LinearAnimationRunner( final int aTargetLatitudeE6, final int aTargetLongitudeE6, final int aSmoothness, final int aDuration) { super(aTargetLatitudeE6, aTargetLongitudeE6, aSmoothness, aDuration); /* Get the current mapview-center. */ final MapView mapview = MapController.this.mOsmv; final IGeoPoint mapCenter = mapview.getMapCenter(); this.mPanPerStepLatitudeE6 = (mapCenter.getLatitudeE6() - aTargetLatitudeE6) / aSmoothness; this.mPanPerStepLongitudeE6 = (mapCenter.getLongitudeE6() - aTargetLongitudeE6) / aSmoothness; this.setName("LinearAnimationRunner"); }
public AbstractAnimationRunner( final int aTargetLatitudeE6, final int aTargetLongitudeE6, final int aSmoothness, final int aDuration) { this.mTargetLatitudeE6 = aTargetLatitudeE6; this.mTargetLongitudeE6 = aTargetLongitudeE6; this.mSmoothness = aSmoothness; this.mStepDuration = aDuration / aSmoothness; /* Get the current mapview-center. */ final MapView mapview = MapController.this.mOsmv; final IGeoPoint mapCenter = mapview.getMapCenter(); this.mPanTotalLatitudeE6 = mapCenter.getLatitudeE6() - aTargetLatitudeE6; this.mPanTotalLongitudeE6 = mapCenter.getLongitudeE6() - aTargetLongitudeE6; }
@Override public boolean onOptionsItemSelected(MenuItem item) { final int id = item.getItemId(); if (id == R.id.maps__menu_accept) { IGeoPoint point = mOverlay.getGeoPoint(); Location location = new Location("medesmapprovider"); location.setLatitude(point.getLatitudeE6() / (double) 1E6); location.setLongitude(point.getLongitudeE6() / (double) 1E6); setResult(RESULT_OK, new Intent().putExtra(MapsConstants.EXTRA_LOCATION, location)); finish(); return true; } else if (id == R.id.maps__menu_map) { showDialog(DIALOG_MAPMODE_ID); return true; } else if (id == R.id.maps__menu_place) { changeMyLocationState(); return true; } return super.onOptionsItemSelected(item); }
@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 onRunAnimation() { final MapView mapview = MapController.this.mOsmv; final IGeoPoint mapCenter = mapview.getMapCenter(); final int panPerStepLatitudeE6 = this.mPanPerStepLatitudeE6; final int panPerStepLongitudeE6 = this.mPanPerStepLongitudeE6; final int stepDuration = this.mStepDuration; try { int newMapCenterLatE6; int newMapCenterLonE6; for (int i = this.mSmoothness; i > 0; i--) { newMapCenterLatE6 = mapCenter.getLatitudeE6() - panPerStepLatitudeE6; newMapCenterLonE6 = mapCenter.getLongitudeE6() - panPerStepLongitudeE6; mapview.setMapCenter(newMapCenterLatE6, newMapCenterLonE6); Thread.sleep(stepDuration); } } catch (final Exception e) { this.interrupt(); } }
public CircleGeofence setCenter(IGeoPoint center) { this.latitudeE6 = center.getLatitudeE6(); this.longitudeE6 = center.getLongitudeE6(); this.cachedGeoPoint = center; return this; }
/** Start animating the map towards the given point. */ @Override public void animateTo(final IGeoPoint point) { animateTo(point.getLatitudeE6() / 1E6, point.getLongitudeE6() / 1E6); }