gpt4 book ai didi

Android 谷歌地图错误 (nControl = mapView.getController();)

转载 作者:行者123 更新时间:2023-11-30 03:52:33 25 4
gpt4 key购买 nike

我已经加载了 Google API 16
使用 Google API 16 编译

此行的错误是“无法解析 mapView”

  <nControl = mapView.getController();>

删除了gen文件夹,清理干净
已重启 Eclipse
任何帮助将不胜感激,因为我是新手并试图为非营利组织制作 map

Activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<com.google.android.maps.MapView
android:id="@+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="AIzaSyC1r4MzsV6jc2J-g335UlIN8WYS6D3hJks"
/>

GoogleMaps3.manifest

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="net.example.googlemaps3.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<user-library android:name="com.google.android.maps" />
</application>

MainActivity.java

 package net.example.googlemaps3;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;

public class MainActivity extends Activity {
MapController nControl;
GeoPoint GeoP;
MapView mapV;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mapV = (MapView) findViewById(R.id.mapView);
mapV.displayZoomControls(true);
mapV.setBuiltInZoomControls(true);

double lat=44.3;
double Longi=-79.8;
GeoP= new GeoPoint((int)(lat*1E6),(int)(Longi*1E6));
nControl = mapView.getController();
nControl.animateTo(GeoP);
nControl.setZoom(12);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}

}

最佳答案

因为你的变量是 mapV 而不是 mapView,你应该继续这条路并重写

nControl = mapView.getController();

作为

nControl = mapV.getController();

关于Android 谷歌地图错误 (nControl = mapView.getController();),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13924746/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com