U có thể có zoom CControl như thế này.
Ở đây tôi đang gắn mã làm cách nào bạn có thể triển khai zoomcontrol.
1 >> Tệp XML phải như thế này.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.android.maps.MapView
android:id="@+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="0l4sCTTyRmXTNo7k8DREHvEaLar2UmHGwnhZVHQ"
/>
<LinearLayout android:id="@+id/zoom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
2 >> Về bạn hoạt động chính bên trong phương thức oncreate thực hiện những điều sau đây. tại đây bạn đang tăng lượt xem của bạn với mapView
mapView = (MapView) findViewById(R.id.mapView);
LinearLayout zoomLayout = (LinearLayout)findViewById(R.id.zoom);
View zoomView = mapView.getZoomControls();
zoomLayout.addView(zoomView,
new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
mapView.displayZoomControls(true);
.................................. ......................... Đây là cách bạn có thể sử dụng điều khiển thu phóng sẵn có của API ..
Bạn có thể có mã tùy chỉnh của riêng mình để thực hiện Phóng to và thu nhỏ như thế này ...
public boolean onKeyDown(int keyCode, KeyEvent event)
{
MapController mc = mapView.getController();
switch (keyCode)
{
case KeyEvent.KEYCODE_3:
mc.zoomIn();
break;
case KeyEvent.KEYCODE_1:
mc.zoomOut();
break;
}
return super.onKeyDown(keyCode, event);
}
..This là làm thế nào tôi đã thực hiện ...
Thanks..Rakesh
Nguồn
2010-08-27 10:55:29
Tôi đã thử triển khai sự kiện onUserInteraction, cho cùng một mục đích nhưng tôi vẫn gặp sự cố. Tôi đang hiển thị một hình ảnh cần được thu nhỏ theo mức thu phóng, vì vậy rõ ràng là tôi muốn gọi phương thức redraw() khi người dùng phóng to. Vấn đề của tôi là onUserInteraction được gọi khi người dùng nhấp vào nút thu phóng, vì vậy zoomLevel chưa được cập nhật và chỉ trên tương tác tiếp theo (nhấp, span, bất kỳ) zoomLevel được cập nhật. Vì vậy, hình ảnh của tôi chỉ được cập nhật sau khi tương tác sau khi thu phóng thực tế. Bất kỳ ý tưởng? – Itsik
Câu hỏi và câu trả lời này đề cập đến API v1, tôi đã thêm câu trả lời mới bên dưới cho người đang sử dụng [Google Maps Android API v2] (https://developers.google.com/maps/documentation/android /) – tarmelop