我有使用GoogleMaps API的應用程序,並且遇到了點擊myLocationButton時無法執行任何操作的問題。所以按鈕是可見的,我看到了我的位置,但是當我點擊按鈕時,它不會將攝像機對準y位置。這是我的代碼:GoogleMaps Android API我的位置問題
1)片段地圖:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
setRetainInstance(true);
mapView = (MapView) v.findViewById(R.id.mapview);
mapView.onCreate(null);
MapsInitializer.initialize(this.getActivity());
mMap = mapView.getMap();
mMap.setMyLocationEnabled(true);
UISettings = mMap.getUiSettings();
UISettings.setMapToolbarEnabled(false);
UISettings.setZoomControlsEnabled(true);
}
2)XML地圖:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:slidingLayer="http://schemas.android.com/apk/res-auto">
<com.google.android.gms.maps.MapView android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
CameraUpdate zoom = CameraUpdateFactory.zoomTo(15); map.moveCamera(center); map.animateCamera(zoom);使用此 –
有時它不會移動,直到它獲得一個準確的位置,然後自動移動相機。 – EdgarMarcoPolo