Continuous zoom preparation
This commit is contained in:
parent
fb1bb6387a
commit
c3481e629b
13 changed files with 86 additions and 76 deletions
|
@ -333,15 +333,6 @@ public class MapUtils {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getLengthXFromMeters(float zoom, double latitude, double longitude, double meters, float tileSize, int widthOfDisplay) {
|
|
||||||
double tileNumberX = MapUtils.getTileNumberX(zoom, longitude);
|
|
||||||
double tileNumberLeft = tileNumberX - ((double) widthOfDisplay) / (2d * tileSize);
|
|
||||||
double tileNumberRight = tileNumberX + ((double) widthOfDisplay) / (2d * tileSize);
|
|
||||||
double dist = getDistance(latitude, getLongitudeFromTile(zoom, tileNumberLeft), latitude, getLongitudeFromTile(zoom,
|
|
||||||
tileNumberRight));
|
|
||||||
|
|
||||||
return (int) ((double) widthOfDisplay / dist * meters);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getPixelShiftX(int zoom, double long1, double long2, int tileSize){
|
public static int getPixelShiftX(int zoom, double long1, double long2, int tileSize){
|
||||||
return (int) ((getTileNumberX(zoom, long1) - getTileNumberX(zoom, long2)) * tileSize);
|
return (int) ((getTileNumberX(zoom, long1) - getTileNumberX(zoom, long2)) * tileSize);
|
||||||
|
|
|
@ -59,22 +59,13 @@ public class DownloadTilesDialog {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final int max = mapSource.getMaximumZoomSupported();
|
final int max = mapSource.getMaximumZoomSupported();
|
||||||
|
// get narrow zoom
|
||||||
final int zoom = mapView.getZoom();
|
final int zoom = mapView.getZoom();
|
||||||
|
|
||||||
// calculate pixel rectangle
|
// calculate pixel rectangle
|
||||||
Rect boundsRect = new Rect(0, 0, mapView.getWidth(), mapView.getHeight());
|
Rect boundsRect = new Rect(0, 0, mapView.getWidth(), mapView.getHeight());
|
||||||
float tileX = (float) MapUtils.getTileNumberX(zoom, mapView.getLongitude());
|
|
||||||
float tileY = (float) MapUtils.getTileNumberY(zoom, mapView.getLatitude());
|
|
||||||
float w = mapView.getCenterPointX();
|
|
||||||
float h = mapView.getCenterPointY();
|
|
||||||
RectF tilesRect = new RectF();
|
|
||||||
final RectF latlonRect = new RectF();
|
final RectF latlonRect = new RectF();
|
||||||
mapView.calculateTileRectangle(boundsRect, w, h, tileX, tileY, tilesRect);
|
mapView.calculateLatLonRectangle(boundsRect, latlonRect);
|
||||||
|
|
||||||
latlonRect.top = (float) MapUtils.getLatitudeFromTile(zoom, tilesRect.top);
|
|
||||||
latlonRect.left = (float) MapUtils.getLongitudeFromTile(zoom, tilesRect.left);
|
|
||||||
latlonRect.bottom = (float) MapUtils.getLatitudeFromTile(zoom, tilesRect.bottom);
|
|
||||||
latlonRect.right = (float) MapUtils.getLongitudeFromTile(zoom, tilesRect.right);
|
|
||||||
|
|
||||||
Builder builder = new AlertDialog.Builder(ctx);
|
Builder builder = new AlertDialog.Builder(ctx);
|
||||||
LayoutInflater inflater = (LayoutInflater)ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater inflater = (LayoutInflater)ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
|
|
@ -41,7 +41,6 @@ import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.DialogInterface.OnDismissListener;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
|
@ -156,12 +155,6 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
||||||
startProgressDialog = new ProgressDialog(this);
|
startProgressDialog = new ProgressDialog(this);
|
||||||
startProgressDialog.setCancelable(true);
|
startProgressDialog.setCancelable(true);
|
||||||
((OsmandApplication) getApplication()).checkApplicationIsBeingInitialized(this, startProgressDialog);
|
((OsmandApplication) getApplication()).checkApplicationIsBeingInitialized(this, startProgressDialog);
|
||||||
startProgressDialog.setOnDismissListener(new OnDismissListener() {
|
|
||||||
@Override
|
|
||||||
public void onDismiss(DialogInterface dialog) {
|
|
||||||
getMapView().refreshMap(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
parseLaunchIntentLocation();
|
parseLaunchIntentLocation();
|
||||||
|
|
||||||
mapView = (OsmandMapTileView) findViewById(R.id.MapView);
|
mapView = (OsmandMapTileView) findViewById(R.id.MapView);
|
||||||
|
@ -177,7 +170,7 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
||||||
startProgressDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
startProgressDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onDismiss(DialogInterface dialog) {
|
public void onDismiss(DialogInterface dialog) {
|
||||||
mapView.refreshMap();
|
mapView.refreshMap(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -412,7 +405,7 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeZoom(int newZoom){
|
public void changeZoom(float newZoom){
|
||||||
boolean changeLocation = settings.AUTO_ZOOM_MAP.get();
|
boolean changeLocation = settings.AUTO_ZOOM_MAP.get();
|
||||||
mapView.getAnimatedDraggingThread().startZooming(newZoom, changeLocation);
|
mapView.getAnimatedDraggingThread().startZooming(newZoom, changeLocation);
|
||||||
if (getMyApplication().accessibilityEnabled())
|
if (getMyApplication().accessibilityEnabled())
|
||||||
|
@ -672,7 +665,7 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
||||||
if(locationLayer.getLastKnownLocation() != null){
|
if(locationLayer.getLastKnownLocation() != null){
|
||||||
Location lastKnownLocation = locationLayer.getLastKnownLocation();
|
Location lastKnownLocation = locationLayer.getLastKnownLocation();
|
||||||
AnimateDraggingMapThread thread = mapView.getAnimatedDraggingThread();
|
AnimateDraggingMapThread thread = mapView.getAnimatedDraggingThread();
|
||||||
int fZoom = mapView.getZoom() < 13 ? 13 : mapView.getZoom();
|
float fZoom = mapView.getFloatZoom() < 13 ? 13 : mapView.getFloatZoom();
|
||||||
thread.startMoving( lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude(), fZoom, false);
|
thread.startMoving( lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude(), fZoom, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -774,8 +767,8 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
if (isMapLinkedToLocation()) {
|
if (isMapLinkedToLocation()) {
|
||||||
if(settings.AUTO_ZOOM_MAP.get() && location.hasSpeed()){
|
if(settings.AUTO_ZOOM_MAP.get() && location.hasSpeed()){
|
||||||
float z = defineZoomFromSpeed(location.getSpeed(), mapView.getZoom());
|
float z = defineZoomFromSpeed(location.getSpeed(), mapView.getFloatZoom());
|
||||||
if(Math.abs(mapView.getZoom() - z) > .33f){
|
if(Math.abs(mapView.getFloatZoom() - z) >= OsmandMapTileView.ZOOM_DELTA_1){
|
||||||
// prevent ui hysteresis (check time interval for autozoom)
|
// prevent ui hysteresis (check time interval for autozoom)
|
||||||
if(now - lastTimeAutoZooming > 5000){
|
if(now - lastTimeAutoZooming > 5000){
|
||||||
lastTimeAutoZooming = now;
|
lastTimeAutoZooming = now;
|
||||||
|
@ -813,7 +806,7 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
||||||
mapView.refreshMap();
|
mapView.refreshMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
public float defineZoomFromSpeed(float speed, int currentZoom){
|
public float defineZoomFromSpeed(float speed, float currentZoom){
|
||||||
DisplayMetrics metrics = new DisplayMetrics();
|
DisplayMetrics metrics = new DisplayMetrics();
|
||||||
getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
||||||
|
|
||||||
|
@ -973,7 +966,7 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
||||||
AnimateDraggingMapThread animatedThread = mapView.getAnimatedDraggingThread();
|
AnimateDraggingMapThread animatedThread = mapView.getAnimatedDraggingThread();
|
||||||
if(animatedThread.isAnimating() && animatedThread.getTargetZoom() != 0){
|
if(animatedThread.isAnimating() && animatedThread.getTargetZoom() != 0){
|
||||||
settings.setMapLocationToShow(animatedThread.getTargetLatitude(), animatedThread.getTargetLongitude(),
|
settings.setMapLocationToShow(animatedThread.getTargetLatitude(), animatedThread.getTargetLongitude(),
|
||||||
animatedThread.getTargetZoom());
|
(int) animatedThread.getTargetZoom());
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.setLastKnownMapZoom(mapView.getZoom());
|
settings.setLastKnownMapZoom(mapView.getZoom());
|
||||||
|
|
|
@ -366,7 +366,7 @@ public class MapActivityLayers {
|
||||||
WptPt loc = toShow.findPointToShow();
|
WptPt loc = toShow.findPointToShow();
|
||||||
if(loc != null){
|
if(loc != null){
|
||||||
mapView.getAnimatedDraggingThread().startMoving(loc.lat, loc.lon,
|
mapView.getAnimatedDraggingThread().startMoving(loc.lat, loc.lon,
|
||||||
mapView.getZoom(), true);
|
mapView.getFloatZoom(), true);
|
||||||
}
|
}
|
||||||
mapView.refreshMap();
|
mapView.refreshMap();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -261,7 +261,7 @@ public class NavigatePointActivity extends Activity implements SearchActivityChi
|
||||||
// in case when it is dialog
|
// in case when it is dialog
|
||||||
if(activity != null) {
|
if(activity != null) {
|
||||||
OsmandMapTileView v = activity.getMapView();
|
OsmandMapTileView v = activity.getMapView();
|
||||||
v.getAnimatedDraggingThread().startMoving(lat, lon, v.getZoom(), true);
|
v.getAnimatedDraggingThread().startMoving(lat, lon, v.getFloatZoom(), true);
|
||||||
} else {
|
} else {
|
||||||
settings.setMapLocationToShow(lat, lon, Math.max(12, settings.getLastKnownMapZoom()),
|
settings.setMapLocationToShow(lat, lon, Math.max(12, settings.getLastKnownMapZoom()),
|
||||||
getString(R.string.point_on_map, lat, lon));
|
getString(R.string.point_on_map, lat, lon));
|
||||||
|
|
|
@ -288,7 +288,7 @@ public class ParkingPositionLayer extends OsmandMapLayer implements ContextMenuL
|
||||||
AnimateDraggingMapThread thread = view.getAnimatedDraggingThread();
|
AnimateDraggingMapThread thread = view.getAnimatedDraggingThread();
|
||||||
LatLon parkingPoint = view.getSettings().getParkingPosition();
|
LatLon parkingPoint = view.getSettings().getParkingPosition();
|
||||||
if (parkingPoint != null) {
|
if (parkingPoint != null) {
|
||||||
int fZoom = view.getZoom() < 15 ? 15 : view.getZoom();
|
float fZoom = view.getFloatZoom() < 15 ? 15 : view.getFloatZoom();
|
||||||
thread.startMoving(parkingPoint.getLatitude(), parkingPoint.getLongitude(), fZoom, true);
|
thread.startMoving(parkingPoint.getLatitude(), parkingPoint.getLongitude(), fZoom, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class AnimateDraggingMapThread {
|
||||||
private float targetRotate = 0;
|
private float targetRotate = 0;
|
||||||
private double targetLatitude = 0;
|
private double targetLatitude = 0;
|
||||||
private double targetLongitude = 0;
|
private double targetLongitude = 0;
|
||||||
private int targetZoom = 0;
|
private float targetZoom = 0;
|
||||||
|
|
||||||
|
|
||||||
public AnimateDraggingMapThread(OsmandMapTileView tileView){
|
public AnimateDraggingMapThread(OsmandMapTileView tileView){
|
||||||
|
@ -107,17 +107,16 @@ public class AnimateDraggingMapThread {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startMoving(final double finalLat, final double finalLon, final int endZoom, final boolean notifyListener){
|
public void startMoving(final double finalLat, final double finalLon, final float endZoom, final boolean notifyListener){
|
||||||
stopAnimatingSync();
|
stopAnimatingSync();
|
||||||
|
|
||||||
double startLat = tileView.getLatitude();
|
double startLat = tileView.getLatitude();
|
||||||
double startLon = tileView.getLongitude();
|
double startLon = tileView.getLongitude();
|
||||||
float rotate = tileView.getRotate();
|
float rotate = tileView.getRotate();
|
||||||
final int startZoom = tileView.getZoom();
|
final float startZoom = tileView.getFloatZoom();
|
||||||
int tileSize = tileView.getSourceTileSize();
|
int tileSize = tileView.getSourceTileSize();
|
||||||
|
|
||||||
|
|
||||||
int mZoom = startZoom;
|
float mZoom = startZoom;
|
||||||
boolean skipAnimation = false;
|
boolean skipAnimation = false;
|
||||||
float mStX = (float) ((MapUtils.getTileNumberX(mZoom, startLon) - MapUtils.getTileNumberX(mZoom, finalLon)) * tileSize);
|
float mStX = (float) ((MapUtils.getTileNumberX(mZoom, startLon) - MapUtils.getTileNumberX(mZoom, finalLon)) * tileSize);
|
||||||
float mStY = (float) ((MapUtils.getTileNumberY(mZoom, startLat) - MapUtils.getTileNumberY(mZoom, finalLat)) * tileSize);
|
float mStY = (float) ((MapUtils.getTileNumberY(mZoom, startLat) - MapUtils.getTileNumberY(mZoom, finalLat)) * tileSize);
|
||||||
|
@ -129,7 +128,7 @@ public class AnimateDraggingMapThread {
|
||||||
mStX = (float) ((MapUtils.getTileNumberX(mZoom, startLon) - MapUtils.getTileNumberX(mZoom, finalLon)) * tileSize);
|
mStX = (float) ((MapUtils.getTileNumberX(mZoom, startLon) - MapUtils.getTileNumberX(mZoom, finalLon)) * tileSize);
|
||||||
mStY = (float) ((MapUtils.getTileNumberY(mZoom, startLat) - MapUtils.getTileNumberY(mZoom, finalLat)) * tileSize);
|
mStY = (float) ((MapUtils.getTileNumberY(mZoom, startLat) - MapUtils.getTileNumberY(mZoom, finalLat)) * tileSize);
|
||||||
}
|
}
|
||||||
final int moveZoom = mZoom;
|
final float moveZoom = mZoom;
|
||||||
// check if animation needed
|
// check if animation needed
|
||||||
skipAnimation = skipAnimation || (Math.abs(moveZoom - startZoom) >= 3 || Math.abs(endZoom - moveZoom) > 3);
|
skipAnimation = skipAnimation || (Math.abs(moveZoom - startZoom) >= 3 || Math.abs(endZoom - moveZoom) > 3);
|
||||||
if (skipAnimation) {
|
if (skipAnimation) {
|
||||||
|
@ -196,7 +195,7 @@ public class AnimateDraggingMapThread {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void animatingZoomInThread(int zoomStart, int zoomEnd, float animationTime, boolean notifyListener){
|
private void animatingZoomInThread(float zoomStart, float zoomEnd, float animationTime, boolean notifyListener){
|
||||||
float curZoom = zoomStart;
|
float curZoom = zoomStart;
|
||||||
animationTime *= Math.abs(zoomEnd - zoomStart);
|
animationTime *= Math.abs(zoomEnd - zoomStart);
|
||||||
// AccelerateInterpolator interpolator = new AccelerateInterpolator(1);
|
// AccelerateInterpolator interpolator = new AccelerateInterpolator(1);
|
||||||
|
@ -234,12 +233,12 @@ public class AnimateDraggingMapThread {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void startZooming(final int zoomEnd, final boolean notifyListener){
|
public void startZooming(final float zoomEnd, final boolean notifyListener){
|
||||||
final float animationTime = ZOOM_ANIMATION_TIME;
|
final float animationTime = ZOOM_ANIMATION_TIME;
|
||||||
startThreadAnimating(new Runnable(){
|
startThreadAnimating(new Runnable(){
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
final int zoomStart = tileView.getZoom();
|
final float zoomStart = tileView.getFloatZoom();
|
||||||
setTargetValues(zoomEnd, tileView.getLatitude(), tileView.getLongitude());
|
setTargetValues(zoomEnd, tileView.getLatitude(), tileView.getLongitude());
|
||||||
animatingZoomInThread(zoomStart, zoomEnd, animationTime, notifyListener);
|
animatingZoomInThread(zoomStart, zoomEnd, animationTime, notifyListener);
|
||||||
pendingRotateAnimation();
|
pendingRotateAnimation();
|
||||||
|
@ -291,7 +290,7 @@ public class AnimateDraggingMapThread {
|
||||||
targetZoom = 0;
|
targetZoom = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTargetValues(int zoom, double lat, double lon){
|
private void setTargetValues(float zoom, double lat, double lon){
|
||||||
targetZoom = zoom;
|
targetZoom = zoom;
|
||||||
targetLatitude = lat;
|
targetLatitude = lat;
|
||||||
targetLongitude = lon;
|
targetLongitude = lon;
|
||||||
|
@ -315,7 +314,7 @@ public class AnimateDraggingMapThread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTargetZoom() {
|
public float getTargetZoom() {
|
||||||
return targetZoom;
|
return targetZoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -302,20 +302,19 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
zoomInButton.setOnClickListener(new View.OnClickListener() {
|
zoomInButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if(view.isZooming()){
|
if (view.isZooming()) {
|
||||||
activity.changeZoom(view.getZoom() + 2);
|
activity.changeZoom(view.getZoom() + 2 );
|
||||||
} else {
|
} else {
|
||||||
activity.changeZoom(view.getZoom() + 1);
|
activity.changeZoom(view.getZoom() + 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
zoomOutButton.setOnClickListener(new View.OnClickListener() {
|
zoomOutButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
activity.changeZoom(view.getZoom() - 1);
|
activity.changeZoom(view.getZoom() - 1 );
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -392,7 +391,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
/////////////////////// Ruler ///////////////////
|
/////////////////////// Ruler ///////////////////
|
||||||
// cache values for ruler
|
// cache values for ruler
|
||||||
ShadowText cacheRulerText = null;
|
ShadowText cacheRulerText = null;
|
||||||
int cacheRulerZoom = 0;
|
float cacheRulerZoom = 0;
|
||||||
double cacheRulerTileX = 0;
|
double cacheRulerTileX = 0;
|
||||||
double cacheRulerTileY = 0;
|
double cacheRulerTileY = 0;
|
||||||
float cacheRulerTextLen = 0;
|
float cacheRulerTextLen = 0;
|
||||||
|
@ -401,16 +400,15 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
// update cache
|
// update cache
|
||||||
if (view.isZooming()) {
|
if (view.isZooming()) {
|
||||||
cacheRulerText = null;
|
cacheRulerText = null;
|
||||||
} else if(view.getZoom() != cacheRulerZoom ||
|
} else if(view.getFloatZoom() != cacheRulerZoom ||
|
||||||
Math.abs(view.getXTile() - cacheRulerTileX) + Math.abs(view.getYTile() - cacheRulerTileY) > 1){
|
Math.abs(view.getXTile() - cacheRulerTileX) + Math.abs(view.getYTile() - cacheRulerTileY) > 1){
|
||||||
cacheRulerZoom = view.getZoom();
|
cacheRulerZoom = view.getFloatZoom();
|
||||||
cacheRulerTileX = view.getXTile();
|
cacheRulerTileX = view.getXTile();
|
||||||
cacheRulerTileY = view.getYTile();
|
cacheRulerTileY = view.getYTile();
|
||||||
double latitude = view.getLatitude();
|
double latitude = view.getLatitude();
|
||||||
double tileNumberLeft = cacheRulerTileX - ((double) view.getWidth()) / (2d * view.getTileSize());
|
double leftLon = view.calcLongitude(- view.getWidth() / 2);
|
||||||
double tileNumberRight = cacheRulerTileX + ((double) view.getWidth()) / (2d * view.getTileSize());
|
double rightLon = view.calcLongitude(+ view.getWidth() / 2);
|
||||||
double dist = MapUtils.getDistance(latitude, MapUtils.getLongitudeFromTile(view.getZoom(), tileNumberLeft), latitude,
|
double dist = MapUtils.getDistance(latitude, leftLon, latitude, rightLon);
|
||||||
MapUtils.getLongitudeFromTile(view.getZoom(), tileNumberRight));
|
|
||||||
double pixDensity = view.getWidth() / dist;
|
double pixDensity = view.getWidth() / dist;
|
||||||
|
|
||||||
double roundedDist = OsmAndFormatter.calculateRoundedDist(dist * screenRulerPercent, view.getContext());
|
double roundedDist = OsmAndFormatter.calculateRoundedDist(dist * screenRulerPercent, view.getContext());
|
||||||
|
|
|
@ -420,7 +420,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
AnimateDraggingMapThread thread = view.getAnimatedDraggingThread();
|
AnimateDraggingMapThread thread = view.getAnimatedDraggingThread();
|
||||||
LatLon pointToNavigate = view.getSettings().getPointToNavigate();
|
LatLon pointToNavigate = view.getSettings().getPointToNavigate();
|
||||||
if (pointToNavigate != null) {
|
if (pointToNavigate != null) {
|
||||||
int fZoom = view.getZoom() < 15 ? 15 : view.getZoom();
|
float fZoom = view.getFloatZoom() < 15 ? 15 : view.getFloatZoom();
|
||||||
thread.startMoving(pointToNavigate.getLatitude(), pointToNavigate.getLongitude(), fZoom, true);
|
thread.startMoving(pointToNavigate.getLatitude(), pointToNavigate.getLongitude(), fZoom, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,9 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
|
|
||||||
protected final int emptyTileDivisor = 16;
|
protected final int emptyTileDivisor = 16;
|
||||||
|
|
||||||
|
public static final float ZOOM_DELTA = 3;
|
||||||
|
public static final float ZOOM_DELTA_1 = 1/3f;
|
||||||
|
|
||||||
|
|
||||||
public interface OnTrackBallListener {
|
public interface OnTrackBallListener {
|
||||||
public boolean onTrackBallEvent(MotionEvent e);
|
public boolean onTrackBallEvent(MotionEvent e);
|
||||||
|
@ -329,9 +332,19 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
public int getZoom() {
|
public int getZoom() {
|
||||||
return (int) zoom;
|
return (int) zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getFloatZoom() {
|
||||||
|
return zoom;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isZooming(){
|
public boolean isZooming(){
|
||||||
return zoom != getZoom();
|
// zooming scale
|
||||||
|
float diff = (zoom - getZoom()) * ZOOM_DELTA;
|
||||||
|
if(Math.abs(diff - Math.round(diff)) < 0.0001) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
// return zoom != getZoom();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMapLocationListener(IMapLocationListener l) {
|
public void setMapLocationListener(IMapLocationListener l) {
|
||||||
|
@ -391,7 +404,30 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
public void setMapPosition(int type) {
|
public void setMapPosition(int type) {
|
||||||
this.mapPosition = type;
|
this.mapPosition = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double calcLongitude(int pixelFromCenter) {
|
||||||
|
return MapUtils.getLongitudeFromTile(getZoom(), getXTile() + pixelFromCenter / getTileSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
public double calcLatitude(int pixelFromCenter) {
|
||||||
|
return MapUtils.getLatitudeFromTile(getZoom(), getXTile() + pixelFromCenter / getTileSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void calculateLatLonRectangle(Rect pixRect, RectF latLonRect) {
|
||||||
|
int z = (int) zoom;
|
||||||
|
float tileX = (float) MapUtils.getTileNumberX(z, getLongitude());
|
||||||
|
float tileY = (float) MapUtils.getTileNumberY(z, getLatitude());
|
||||||
|
float w = getCenterPointX();
|
||||||
|
float h = getCenterPointY();
|
||||||
|
RectF tilesRect = new RectF();
|
||||||
|
calculateTileRectangle(pixRect, w, h, tileX, tileY, tilesRect);
|
||||||
|
|
||||||
|
latlonRect.top = (float) MapUtils.getLatitudeFromTile(z, tilesRect.top);
|
||||||
|
latlonRect.left = (float) MapUtils.getLongitudeFromTile(z, tilesRect.left);
|
||||||
|
latlonRect.bottom = (float) MapUtils.getLatitudeFromTile(z, tilesRect.bottom);
|
||||||
|
latlonRect.right = (float) MapUtils.getLongitudeFromTile(z, tilesRect.right);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void calculateTileRectangle(Rect pixRect, float cx, float cy, float ctilex, float ctiley, RectF tileRect) {
|
public void calculateTileRectangle(Rect pixRect, float cx, float cy, float ctilex, float ctiley, RectF tileRect) {
|
||||||
float x1 = calcDiffTileX(pixRect.left - cx, pixRect.top - cy);
|
float x1 = calcDiffTileX(pixRect.left - cx, pixRect.top - cy);
|
||||||
|
|
|
@ -82,8 +82,11 @@ public class PointLocationLayer extends OsmandMapLayer {
|
||||||
int locationX = view.getMapXForPoint(lastKnownLocation.getLongitude());
|
int locationX = view.getMapXForPoint(lastKnownLocation.getLongitude());
|
||||||
int locationY = view.getMapYForPoint(lastKnownLocation.getLatitude());
|
int locationY = view.getMapYForPoint(lastKnownLocation.getLatitude());
|
||||||
|
|
||||||
int radius = MapUtils.getLengthXFromMeters(view.getZoom(), view.getLatitude(), view.getLongitude(),
|
double lonLeft = view.calcLongitude(- view.getWidth() / 2);
|
||||||
lastKnownLocation.getAccuracy(), view.getTileSize(), view.getWidth());
|
double lonRight = view.calcLongitude(+ view.getWidth() / 2);
|
||||||
|
double dist = MapUtils.getDistance(view.getLatitude(), lonLeft, view.getLatitude(), lonRight);
|
||||||
|
int radius = (int) (((double) view.getWidth()) / dist * lastKnownLocation.getAccuracy());
|
||||||
|
|
||||||
if (radius > RADIUS * dm.density) {
|
if (radius > RADIUS * dm.density) {
|
||||||
int allowedRad = Math.min(view.getWidth() / 2, view.getHeight() / 2);
|
int allowedRad = Math.min(view.getWidth() / 2, view.getHeight() / 2);
|
||||||
canvas.drawCircle(locationX, locationY, Math.min(radius, allowedRad), area);
|
canvas.drawCircle(locationX, locationY, Math.min(radius, allowedRad), area);
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class RouteInfoLayer extends OsmandMapLayer implements IRouteInformationL
|
||||||
if(info.getDescriptionRoute() != null) {
|
if(info.getDescriptionRoute() != null) {
|
||||||
contextMenu.setLocation(new LatLon(l.getLatitude(), l.getLongitude()), info.getDescriptionRoute());
|
contextMenu.setLocation(new LatLon(l.getLatitude(), l.getLongitude()), info.getDescriptionRoute());
|
||||||
}
|
}
|
||||||
view.getAnimatedDraggingThread().startMoving(l.getLatitude(), l.getLongitude(), view.getZoom(), true);
|
view.getAnimatedDraggingThread().startMoving(l.getLatitude(), l.getLongitude(), view.getFloatZoom(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
view.refreshMap();
|
view.refreshMap();
|
||||||
|
@ -91,7 +91,7 @@ public class RouteInfoLayer extends OsmandMapLayer implements IRouteInformationL
|
||||||
if(info.getDescriptionRoute() != null){
|
if(info.getDescriptionRoute() != null){
|
||||||
contextMenu.setLocation(new LatLon(l.getLatitude(), l.getLongitude()), info.getDescriptionRoute());
|
contextMenu.setLocation(new LatLon(l.getLatitude(), l.getLongitude()), info.getDescriptionRoute());
|
||||||
}
|
}
|
||||||
view.getAnimatedDraggingThread().startMoving(l.getLatitude(), l.getLongitude(), view.getZoom(), true);
|
view.getAnimatedDraggingThread().startMoving(l.getLatitude(), l.getLongitude(), view.getFloatZoom(), true);
|
||||||
}
|
}
|
||||||
view.refreshMap();
|
view.refreshMap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class RouteLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private final RoutingHelper helper;
|
private final RoutingHelper helper;
|
||||||
private Rect boundsRect;
|
private Rect boundsRect;
|
||||||
private RectF tileRect;
|
private RectF latlonRect;
|
||||||
private List<Location> points = new ArrayList<Location>();
|
private List<Location> points = new ArrayList<Location>();
|
||||||
private Paint paint;
|
private Paint paint;
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ public class RouteLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private void initUI() {
|
private void initUI() {
|
||||||
boundsRect = new Rect(0, 0, view.getWidth(), view.getHeight());
|
boundsRect = new Rect(0, 0, view.getWidth(), view.getHeight());
|
||||||
tileRect = new RectF();
|
latlonRect = new RectF();
|
||||||
paint = new Paint();
|
paint = new Paint();
|
||||||
fluorescent = view.getSettings().FLUORESCENT_OVERLAYS.get();
|
fluorescent = view.getSettings().FLUORESCENT_OVERLAYS.get();
|
||||||
if (view.getSettings().FLUORESCENT_OVERLAYS.get()) {
|
if (view.getSettings().FLUORESCENT_OVERLAYS.get()) {
|
||||||
|
@ -77,12 +77,11 @@ public class RouteLayer extends OsmandMapLayer {
|
||||||
} else {
|
} else {
|
||||||
boundsRect = new Rect(0, 0, w, h);
|
boundsRect = new Rect(0, 0, w, h);
|
||||||
}
|
}
|
||||||
view.calculateTileRectangle(boundsRect, view.getCenterPointX(), view.getCenterPointY(), view.getXTile(), view.getYTile(),
|
view.calculateLatLonRectangle(boundsRect, latlonRect);
|
||||||
tileRect);
|
double topLatitude = latlonRect.top;
|
||||||
double topLatitude = MapUtils.getLatitudeFromTile(view.getZoom(), tileRect.top);
|
double leftLongitude = latlonRect.left;
|
||||||
double leftLongitude = MapUtils.getLongitudeFromTile(view.getZoom(), tileRect.left);
|
double bottomLatitude = latlonRect.bottom;
|
||||||
double bottomLatitude = MapUtils.getLatitudeFromTile(view.getZoom(), tileRect.bottom);
|
double rightLongitude = latlonRect.right;
|
||||||
double rightLongitude = MapUtils.getLongitudeFromTile(view.getZoom(), tileRect.right);
|
|
||||||
double lat = topLatitude - bottomLatitude + 0.1;
|
double lat = topLatitude - bottomLatitude + 0.1;
|
||||||
double lon = rightLongitude - leftLongitude + 0.1;
|
double lon = rightLongitude - leftLongitude + 0.1;
|
||||||
fillLocationsToShow(topLatitude + lat, leftLongitude - lon, bottomLatitude - lat, rightLongitude + lon);
|
fillLocationsToShow(topLatitude + lat, leftLongitude - lon, bottomLatitude - lat, rightLongitude + lon);
|
||||||
|
|
Loading…
Reference in a new issue