我的MapView出现问题,因为它没有加载地图。我一直在阅读,并发现许多人有同样的问题。我检查所有可能存在的问题,似乎一切正常:PAndroid MapView未加载
在清单中,是标签
我有标签之前
在仿真器内部3G工作正常,因为我可以导航浏览器和谷歌地图加载完美
我检查了两次我的ApiKey,似乎没事。使用Windows系统,因此在cmd我导航到Java keytool的所在的文件夹,一旦有我执行下一指令Im来获取指纹,然后我ApiKey:
的keytool -list -alias androiddebugkey -storepass的android -keypass机器人 - 键器C:\路径\其中\中\文件\是\位于\ debug.keystore
下面是我的一些代码:
public class mapa extends MapActivity {
private MapView mMapView = null;
private MapController mc = null;
/** Called when the Activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mapa);
GeoPoint gPoint = new GeoPoint(40331175,-3765780);
mMapView = (MapView) findViewById(R.id.mView);
mMapView.setSatellite(true);
mMapView.setBuiltInZoomControls(true);
mc = mMapView.getController();
mc.setZoom(15);
mc.setCenter(gPoint);
}
的XML布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<com.google.android.maps.MapView
android:id="@+id/mView"
android:layout_width="fill_parent"
android:layout_height="375dp"
android:padding="5dp"
android:enabled="true"
android:clickable="true"
android:apiKey="My_Api_Key" />
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="3dp"
android:orientation="vertical">
<TextView
android:id="@+id/tMapa"
android:text="Último dato"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
//Here i have some other info, but its not relevant to the problem, since all this views loads properly :P
</RelativeLayout>
</LinearLayout>
AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pfc.android"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INERNET" />
<uses-permission android:name="android.permission.WRITE_GSERVICES" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<uses-library android:name="com.google.android.maps" />
<!-- I've got here some others Activities declared -->
<!-- This is the map Activity -->
<activity android:name=".mapa"
android:label="@string/app_name"
class=".mapa">
</activity>
</application>
<uses-sdk android:minSdkVersion="4" />
</manifest>
所以,我不知道我能做些什么来解决这个问题。
任何人都可以帮助我吗? :D
”未加载“是指MapView显示正常,但我能看到的唯一东西是灰色方块,意思是”地图未加载“。无论如何,我发现我的问题的解决方案,ApiKey是正确的,除了互联网使用权限Manifiest之外,其他一切都是正确的。我错误地将INTERNET输入INERNET¬_¬'我不明白为什么Eclipse不会提醒你:P – Kitinz 2010-10-01 08:45:44