我想实现谷歌地图,但我现在面临的一些问题的。 问题是,当我加载我的应用程序时,它只显示地图的网格(而不是地图的图像)。谷歌地图Android中只显示网格
这里是我的代码...任何人都可以看到这个问题?
的Xml主要
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey=" api key"
android:clickable="true"
android:enabled="true" />
清单文件
package="info.org.NewMap"
android:versionCode="1"
android:versionName="1.0" >
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
android:name=".NewMapActivity"
android:label="@string/app_name" >
的Java类
package info.org.NewMap;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
public class NewMapActivity extends MapActivity {
/** Called when the activity is first created. */
private MapView mapView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.map_view);
mapView.setBuiltInZoomControls(true);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
其次Java文件
package info.org.NewMap;
import java.util.ArrayList;
import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.Drawable;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;
public class CustomItemizedOverlay extends ItemizedOverlay {
private ArrayList mapOverlays = new ArrayList();
private Context context;
public CustomItemizedOverlay(Drawable defaultMarker) {
super(boundCenterBottom(defaultMarker));
}
public CustomItemizedOverlay(Drawable defaultMarker, Context context) {
this(defaultMarker);
this.context = context;
}
@Override
protected OverlayItem createItem(int i) {
return mapOverlays.get(i);
}
@Override
public int size() {
return mapOverlays.size();
}
@Override
protected boolean onTap(int index) {
OverlayItem item = mapOverlays.get(index);
AlertDialog.Builder dialog = new AlertDialog.Builder(context);
dialog.setTitle(item.getTitle());
dialog.setMessage(item.getSnippet());
dialog.show();
return true;
}
public void addOverlay(OverlayItem overlay) {
mapOverlays.add(overlay);
this.populate();
}
}
2012-06-22
Youddh
+0
你给正确的地图API密钥 –
+0
是你是对的问题是API密钥.. –