我已经加载
了 Google API 16 使用 Google API 16 进行编译
此行的错误是“mapView 无法解析”
<nControl = mapView.getController();>
已删除 gen 文件夹,清理干净
已重新启动 Eclipse
任何帮助将不胜感激,因为我是新手并试图为非营利组织制作地图
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;
}
}