我使用的MapsActivity
错误显示cannot resolve method 'setBuiltInZoomControls(boolean)
'
和cannot resolve method 'getController()'
和cannot resolve method 'setUseDataConnection(boolean)'
这是我的MapsActivity.java
package com.example.app6;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.vision.barcode.Barcode;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
MapView mapView = new MapView(this, 256);
mapView.setClickable(true);
mapView.setBuiltInZoomControls(true);
setContentView(mapView);
mapView.getController().setZoom(14);
mapView.getController().setCenter(new Barcode.GeoPoint(52.221,6.893));
mapView.setUseDataConnection(false);
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Jaipur and move the camera
LatLng jpr = new LatLng(26.8473727, 75.8104005);
mMap.addMarker(new MarkerOptions().position(jpr).title("Marker in Jaipur"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(jpr));
}
}
答案 0 :(得分:0)
问题是您使用的是com.google.android.gms.maps.MapView;
但要在mapView上使用setBuiltInZoomControls()
,您应该使用com.google.android.maps.MapView
。
问题是你正在尝试新旧 Google Maps API
<com.google.android.maps.MapView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/mapview"
android:clickable="true"
android:apiKey="your key">
但我的建议是;使用最新版本的Google Maps Android API