我正在尝试实施谷歌地图 V2,但地图显示为空白。我已经编辑了清单,创建了 xml 布局和活动,但地图显示为空白。
这是我对清单所做的:
<permission
android:name="com.biznismap.com.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.biznismap.com.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
并将其添加为清单中应用程序节点的第一个子节点:
<uses-library android:name="com.google.android.maps" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my_key" />
这是我的地图 xml 布局:
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="my_key"
android:clickable="true" />
这是我的地图活动:
public class ListingMap extends MapActivity {
private HelloItemizedOverlay itemizedoverlay;
private List<Overlay> mapOverlays;
private String lat, lng;
@Override
protected boolean isRouteDisplayed() {
return false;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listing_map);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
mapOverlays = mapView.getOverlays();
Drawable drawable = this.getResources().getDrawable(
R.drawable.ic_launcher);
itemizedoverlay = new HelloItemizedOverlay(drawable);
getExtras();
}
private void getExtras() {
Bundle extras = getIntent().getExtras();
lat = extras.getString("lat");
lng = extras.getString("lng");
Log.v("--", lat+" "+lng);
float latitude=Float.valueOf(lat);
float longitude=Float.valueOf(lng);
GeoPoint point = new GeoPoint((int)(latitude * 1E6),(int)(longitude * 1E6));
OverlayItem overlayitem = new OverlayItem(point, "Hola, Mundo!",
"I'm in Mexico City!");
itemizedoverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedoverlay);
}
}
所以一切都很顺利,但是当我想显示一些东西时,地图是空白的,我从模拟器中得到了这个:
06-02 17:09:26.921: E/MapActivity(1772): Couldn't get connection factory client
那么我哪里出错了,我该如何解决这个问题?