fix multitouch zooming
git-svn-id: https://osmand.googlecode.com/svn/trunk@336 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
3b2ece13ba
commit
ebe7501c8b
1 changed files with 18 additions and 12 deletions
|
@ -703,7 +703,10 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onZoomEnded(float distance, float relativeToStart) {
|
public void onZoomEnded(float distance, float relativeToStart) {
|
||||||
onZooming(distance, relativeToStart);
|
float dz = (float) (Math.log(relativeToStart) / Math.log(2) * 1.5);
|
||||||
|
float calcZoom = initialMultiTouchZoom + dz;
|
||||||
|
setZoom(Math.round(calcZoom));
|
||||||
|
zoomPositionChanged(getFloatZoom());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -713,21 +716,24 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
initialMultiTouchLocation = getLatLonFromScreenPoint(centerPoint.x, centerPoint.y);
|
initialMultiTouchLocation = getLatLonFromScreenPoint(centerPoint.x, centerPoint.y);
|
||||||
initialMultiTouchZoom = zoom;
|
initialMultiTouchZoom = zoom;
|
||||||
}
|
}
|
||||||
|
private void zoomPositionChanged(float calcZoom){
|
||||||
|
float dtx = calcDiffTileX(getCenterPointX() - initialMultiTouchCenterPoint.x, getCenterPointY() - initialMultiTouchCenterPoint.y);
|
||||||
|
float dty = calcDiffTileY(getCenterPointX() - initialMultiTouchCenterPoint.x, getCenterPointY() - initialMultiTouchCenterPoint.y);
|
||||||
|
double tx = MapUtils.getTileNumberX(calcZoom, initialMultiTouchLocation.getLongitude());
|
||||||
|
double ty = MapUtils.getTileNumberY(calcZoom, initialMultiTouchLocation.getLatitude());
|
||||||
|
double lat = MapUtils.getLatitudeFromTile(calcZoom, ty + dty);
|
||||||
|
double lon = MapUtils.getLongitudeFromTile(calcZoom, tx + dtx);
|
||||||
|
setLatLon(lat, lon);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onZooming(float distance, float relativeToStart) {
|
public void onZooming(float distance, float relativeToStart) {
|
||||||
float dz = (float) (Math.log(relativeToStart) / Math.log(2) * 1.5);
|
float dz = (float) (Math.log(relativeToStart) / Math.log(2) * 1.5);
|
||||||
float dtx = calcDiffTileX(getCenterPointX() - initialMultiTouchCenterPoint.x, getCenterPointY() - initialMultiTouchCenterPoint.y);
|
float calcZoom = initialMultiTouchZoom + dz;
|
||||||
float dty = calcDiffTileY(getCenterPointX() - initialMultiTouchCenterPoint.x, getCenterPointY() - initialMultiTouchCenterPoint.y);
|
if(Math.abs(calcZoom - zoom) > 0.05){
|
||||||
double tx = MapUtils.getTileNumberX(getFloatZoom(), initialMultiTouchLocation.getLongitude());
|
setZoom(calcZoom);
|
||||||
double ty = MapUtils.getTileNumberY(getFloatZoom(), initialMultiTouchLocation.getLatitude());
|
zoomPositionChanged(calcZoom);
|
||||||
double lat = MapUtils.getLatitudeFromTile(getFloatZoom(), ty + dty);
|
|
||||||
double lon = MapUtils.getLongitudeFromTile(getFloatZoom(), tx + dtx);
|
|
||||||
|
|
||||||
|
|
||||||
if(Math.abs(initialMultiTouchZoom + dz - zoom) > 0.05){
|
|
||||||
setZoom(initialMultiTouchZoom + dz);
|
|
||||||
setLatLon(lat, lon);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue