編輯:我發現我的問題,請參見下面谷歌地圖API的手勢不工作(變焦旋轉...)
我的答案原帖:
我創建一個包含地圖的活動,但我無法添加縮放和其他手勢功能。我可以槍王放大,我可以添加+/-符號來放大通過
googleMap.getUiSettings().setAllGesturesEnabled(true);
這是我的代碼:
活動的XML(tracking_order.xml)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<fragment
android:id="@+id/mapFragment"
class="com.example.OrderMapFragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3" />
<FrameLayout
android:id="@+id/clientsFragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
OrderMapFragment.java
public class OrderMapFragment extends SupportMapFragment implements OnMapReadyCallback, GoogleMap.OnMarkerClickListener {
public static OrderMapFragment newInstance() {
OrderMapFragment fragment = new OrderMapFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
((OrderMapFragment.OnOrderMarkerClickListener) context).setMapObject(this);
getMapAsync(this);
}
@Override
public void onMapReady(final GoogleMap googleMap) {
googleMap.getUiSettings().setZoomControlsEnabled(true); //this one is working
googleMap.getUiSettings().setZoomGesturesEnabled(true); //not working
googleMap.getUiSettings().setAllGesturesEnabled(true); //not working
// ... (removed code used to fetch markers data)
}
@Override
public boolean onMarkerClick(Marker marker) {
return listener.filterListByMarker(marker);
}
public interface OnOrderMarkerClickListener {
/**
* Action to be taken when a marker has been clicked
*
* @param marker
* @return true if the listener has consumed the event (i.e., the default behavior should not occur);
* false otherwise (i.e., the default behavior should occur).
* The default behavior is for the camera to move to the marker and an info window to appear.
*/
boolean filterListByMarker(Marker marker); //the class that implements this doesn't do anything for now it just returns false
}
}
謝謝
在fi處我已經嘗試了沒有任何3條線。然後我嘗試了'setZoomControlsEnabled',但它不是我所需要的,然後我單獨嘗試了其他每個人,但都沒有工作。然後我把所有這些問題提出來 – PhpLou