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
|
||||
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);
|
||||
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
|
||||
public void onZooming(float distance, float relativeToStart) {
|
||||
float dz = (float) (Math.log(relativeToStart) / Math.log(2) * 1.5);
|
||||
float dtx = calcDiffTileX(getCenterPointX() - initialMultiTouchCenterPoint.x, getCenterPointY() - initialMultiTouchCenterPoint.y);
|
||||
float dty = calcDiffTileY(getCenterPointX() - initialMultiTouchCenterPoint.x, getCenterPointY() - initialMultiTouchCenterPoint.y);
|
||||
double tx = MapUtils.getTileNumberX(getFloatZoom(), initialMultiTouchLocation.getLongitude());
|
||||
double ty = MapUtils.getTileNumberY(getFloatZoom(), initialMultiTouchLocation.getLatitude());
|
||||
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);
|
||||
float calcZoom = initialMultiTouchZoom + dz;
|
||||
if(Math.abs(calcZoom - zoom) > 0.05){
|
||||
setZoom(calcZoom);
|
||||
zoomPositionChanged(calcZoom);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue