Skip to content

Commit 134c0c8

Browse files
committed
fix set rotate
1 parent 29b7019 commit 134c0c8

File tree

2 files changed

+15
-42
lines changed

2 files changed

+15
-42
lines changed

library/src/main/java/com/jiahuan/svgmapview/library/SVGMapController.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,12 @@ public void setCurrentZoomValue(float zoom)
115115
*/
116116
public void setCurrentRotationDegrees(float degrees)
117117
{
118-
this.mapMainView.setCurrentRotationDegrees(degrees);
118+
setCurrentRotationDegrees(degrees, mapMainView.getWidth() / 2, mapMainView.getHeight() / 2);
119+
}
120+
121+
public void setCurrentRotationDegrees(float degrees, float pivotX, float pivotY)
122+
{
123+
this.mapMainView.setCurrentRotationDegrees(degrees, pivotX, pivotY);
119124
}
120125

121126

library/src/main/java/com/jiahuan/svgmapview/library/core/componet/MapMainView.java

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -402,13 +402,16 @@ public float getCurrentRotateDegrees()
402402
return this.currentRotateDegrees;
403403
}
404404

405-
public void setCurrentRotationDegrees(float degrees)
405+
public void setCurrentRotationDegrees(float degrees, float pivotX, float pivotY)
406406
{
407-
this.matrix.postRotate(-currentRotateDegrees + degrees);
408-
this.rotateDegrees = this.currentRotateDegrees = degrees;
409-
setCurrentRotateDegreesWithRule();
410-
refresh();
411-
mapCenter(true, true);
407+
if (isRotationGestureEnabled)
408+
{
409+
this.matrix.postRotate(-currentRotateDegrees + degrees, pivotX, pivotY);
410+
this.rotateDegrees = this.currentRotateDegrees = degrees;
411+
setCurrentRotateDegreesWithRule();
412+
refresh();
413+
mapCenter(true, true);
414+
}
412415
}
413416

414417
public float getCurrentZoomValue()
@@ -453,41 +456,6 @@ public void setMinZoomValue(float minZoomValue)
453456
this.minZoomValue = minZoomValue;
454457
}
455458

456-
public void zoomBy(float zoomRatio, float pivotX, float pivotY)
457-
{
458-
float zoom = getCurrentZoomValue();
459-
float zoomdis = zoomRatio;
460-
if (zoomRatio > 1)
461-
{
462-
if (zoomRatio * zoom > maxZoomValue)
463-
{
464-
zoomdis = maxZoomValue / zoom;
465-
zoom = maxZoomValue;
466-
}
467-
else
468-
{
469-
zoom *= zoomRatio;
470-
zoomdis = zoomRatio;
471-
}
472-
}
473-
else if (zoomRatio < 1)
474-
{
475-
if (zoom * zoomRatio < minZoomValue)
476-
{
477-
zoomdis = minZoomValue / zoom;
478-
zoom = minZoomValue;
479-
}
480-
else
481-
{
482-
zoom *= zoomRatio;
483-
zoomdis = zoomRatio;
484-
}
485-
}
486-
this.zoom = this.currentZoom = zoom;
487-
this.matrix.postScale(zoomdis, zoomdis, pivotX, pivotY);
488-
this.refresh();
489-
}
490-
491459

492460
public float[] getMapCoordinateWithScreenCoordinate(float x, float y)
493461
{

0 commit comments

Comments
 (0)