我有一张static
地图图片,我希望它focus/zoom
到地图上的特定点(例如,当用户搜索特定位置时)。
到目前为止,这是我获取地图displaying
,zooming
和panning
的方式,而且效果很好。
public class MapDisplayActivity extends Activity implements OnTouchListener {
private static final String TAG = "Touch";
// These matrices will be used to move and zoom image
Matrix matrix = new Matrix();
Matrix savedMatrix = new Matrix();
// We can be in one of these 3 states
static final int NONE = 0;
static final int DRAG = 1;
static final int ZOOM = 2;
int mode = NONE;
// Remember some things for zooming
PointF start = new PointF();
PointF mid = new PointF();
float oldDist = 1f;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mappage);
ImageView view = (ImageView) findViewById(R.id.imageView2);
view.setOnTouchListener(this);
}
我正在RelativeLayout
使用ImageView
。