我一直在谷歌上寻找很多关于这个问题的信息,但我还没有解决。地图已显示,但我位于我想要的位置并且仍然给我同样的失败:
06-09 12:10:57.231:I/MapActivity(1532):处理网络更改通知:CONNECTED 06-09 12:10:57.231:W/IdleConnectionHandler(1532):删除从未存在的连接!06-09 12:11:04.829:W/KeyCharacterMap(1532):无法打开 keycharmap 文件 06-09 12:11:04.829:W/KeyCharacterMap(1532):加载 keycharmap 文件时出错 06-09 12:11:04.829 :W/KeyCharacterMap(1532):使用默认键盘映射 06-09 12:11:57.080:I/MapActivity(1785):处理网络更改通知:CONNECTED 06-09 12:11:57.080:E/MapActivity(1785):Couln '不获取连接工厂客户端
而且我不明白,因为我已经按照所有步骤生成了 api 密钥,我的 Activity 从 MapActivity 扩展,并且我添加了我的 android 清单许可证和库。
清单.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.XXX.XXX"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<uses-library android:name="com.google.android.maps"/>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Activities.Gmaps"/>
</application>
</manifest>
地图活动
import android.os.Bundle;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
public class Gmaps extends MapActivity{
private MapView mapa = null;
private MapController control = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gmaps);
mapa = (MapView)findViewById(R.id.mapa);
mapa.setBuiltInZoomControls(true);
Double latitud = 40.4166909;
Double longitud = -3.7003454;
GeoPoint loc = new GeoPoint(latitud.intValue(), longitud.intValue());
control = mapa.getController();
control.setCenter(loc);
control.setZoom(7);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
gmaps.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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/mapa"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="0htJ1gM0WymyYYokI3eUunfuJ2-XXXXXXXXX"
android:clickable="true"/>
</RelativeLayout>
对不起我的英语不好 !!杰杰:)