我已经构建了一个为我做一些坐标计算的应用程序。它工作得很好,它从我建立的数据库中检索点。我现在想要做的是按下菜单按钮时显示地图。我做了一个简单的地图显示教程。这就是它运行时的全部功能。但是当我尝试将我在应用中完成的操作合并时,我根本没有运气。Android:如何在Android应用中显示Google地图?
所以这里是我做过的一些项目,也许有人可以帮助我。
下面是我的android manifest.xml中的重要线路
<uses-library android:name="com.google.android.maps" android:required="true"/>
<uses-permission android:name="android.permission.INTERNET" />
这里是地图显示活动
<com.google.android.maps.MapView
android:id="@+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="0EVD3Q_WMbtaa_vIjrPoaiN7Egbs8amSorNF-qw"
/>
我在主应用程序有一个菜单项的XML,我想要调用地图(我想稍后传递坐标..但是现在,如果它只是简单地显示我会很高兴)在这段代码中,我试图调用地图的情况语句3。
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case 1:
String v_band1 = spin2.getSelectedItem().toString();
Intent myIntent2 = new Intent(Tower.this, BuildList.class);
myIntent2.putExtra("BAND", v_band1);
Tower.this.startActivity(myIntent2);
return true;
case 2:
Intent myIntent = new Intent(Tower.this, Activity2.class);
Tower.this.startActivity(myIntent);
return true;
case 3:
Intent myIntent1 = new Intent(Tower.this, Mapit.class);
Tower.this.startActivity(myIntent1);
return true;
case 4:
loadspinner();
return true;
}
return false;
}
在测试程序
存在在类
import com.google.android.maps.MapActivity;
的顶部。在我的新应用程序时,您在import语句获得“进口com.google开始输入进口线。 android.maps“。并且MapActivity或其他任何东西都不会像测试教程中那样选择。我究竟做错了什么??我尝试粘贴我的整个Android Manfiest.xml以及来自视图的XML以显示地图,但在这里却没有显示整个东西。所以我添加了googlemaps行来向你展示我使用它。
<uses-library android:name="com.google.android.maps" android:required="true"/>
确保您的应用的目标是包含Google地图库的目标。通常,包含“Google Inc.”的那些字符串在他们的名字。 – Cristian 2010-09-02 13:14:48
但是发生了什么?任何日志,来自logcat的异常? – LordTwaroog 2010-09-02 14:08:51