【发布时间】:2017-07-22 23:13:09
【问题描述】:
编辑:我发现了我的问题,请参阅下面的答案
原帖:
我正在创建一个包含地图的活动,但我无法添加缩放和其他手势功能。我可以双击放大,我可以添加 +/- 符号来放大
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
}
}
谢谢
【问题讨论】:
标签: android google-maps pinchzoom