目前我正在處理我的項目中的谷歌地圖。 我正在使用下面的API版本和谷歌地圖顯示。谷歌地圖縮放功能無法正常工作
android.gms:play-services-maps:9.0.2
android.gms:play-services-location:9.0.2
問題:
當我嘗試放大觸摸地圖,谷歌地圖不放大和 我無法移動地圖上看到另一個位置了。
這裏是我的代碼:
@Override
public void onMapReady(GoogleMap googleMap) {
//googleMap.getUiSettings().setZoomControlsEnabled(true);
mMap = googleMap;
Log.i(TAG, "onMapReady");
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
Toast.makeText(this,"Please enable GPS location on your phone",Toast.LENGTH_SHORT).show();
return;
}
Log.i(TAG, "my location enabled");
mMap.setMyLocationEnabled(true);
map.animateCamera(CameraUpdateFactory.zoomTo(14), 2000, null);
buildGoogleApiClient();
if (mMap == null) {
return;
}
/* currentLatLng= new LatLng (currentLocationLatitude,currentLocationLongitude);
Log.i(TAG,"inside onMapready --->");*/
}
protected synchronized void buildGoogleApiClient() {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
mGoogleApiClient.connect();
}
* XML文件包括* 這是我使用的顯示谷歌地圖的XML佈局文件。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="horizontal"
xmlns:app="http://schemas.android.com/apk/res-auto">
<fragment android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.mega.hertz.seeky.MainActivity"/>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="vertical"
android:paddingBottom="@dimen/vertical_page_margin"
android:paddingLeft="@dimen/horizontal_page_margin"
android:paddingRight="@dimen/horizontal_page_margin"
android:paddingTop="@dimen/margin_small">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="50dp">
<fragment
android:id="@+id/autocomplete_fragment"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>
分享您的XML文件 –
您好,我已經包括xml文件 – user1439582