ArcGIS for android提供的放大缩小方法只能以屏幕中心为中心点放大缩小。以下方法是以任意点为中心放大缩小。
/**
* 以一点为中心放大缩小
*
* @param point
* 放大或缩小的中心
* @param res
* 分辨率
*/
public void zoomToResolution(Point point, double res) {
Point pScreen = mapView.toScreenPoint(point);
// 将该点平移到地图中心
mapView.zoomToResolution(point, res);
// 放大缩小后将该点重新移回pScreen处
Point pMirrScreen = new Point(mapView.getWidth() - pScreen.getX(),
mapView.getHeight() - pScreen.getY());
mapView.zoomToResolution(mapView.toMapPoint(pMirrScreen), res);
}
/**
* 以一点为中心放大或缩小
*
* @param point
* @param scale
* 比例尺
*/
public void zoomToScale(Point point, double scale) {
Point radarScreenP = mapView.toScreenPoint(point);
mapView.zoomToScale(point, scale);
Point pMirrScreen = new Point(mapView.getWidth() - radarScreenP.getX(),
mapView.getHeight() - radarScreenP.getY());
mapView.zoomToScale(mapView.toMapPoint(pMirrScreen), scale);
}