相关疑难解决方法(0)

api v2中的mapview和cameraupdate

为什么CameraUpdateFactory类在我的项目中不起作用?如果应用程序执行以下命令,应用程序将崩溃:CameraUpdate pino = CameraUpdateFactory.newLatLng(new LatLng(location.getLatitude(),location.getLongitude())); 如果我删除该行(当然还有下一行),代码将成功启动并显示地图.我需要mapView,我需要使用新的api v2.我以这种方式在布局中声明mapView:

        <com.google.android.gms.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="http://schemas.android.com/apk/res-auto"

    android:id="@+id/mappa"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_below="@+id/buttonBar"

    map:uiZoomControls="false"
     />
Run Code Online (Sandbox Code Playgroud)

然后在mainActivity.java中我写了这个:

    public class MainActivity extends FragmentActivity    implements LocationListener, LocationSource { 
public static boolean locatingMe=true;
public GoogleMap mappa;
public MapView mapView;
private OnLocationChangedListener onLocationChangedListener;
private LocationManager locationManager;




@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mapView = (MapView) findViewById(R.id.mappa);
    mapView.onCreate(savedInstanceState);


        locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);

    //You may want to pass a different provider in as the first arg here
    //depending on the location accuracy that …
Run Code Online (Sandbox Code Playgroud)

google-maps-api-2 android-mapview

15
推荐指数
1
解决办法
8861
查看次数

标签 统计

android-mapview ×1

google-maps-api-2 ×1