安卓:我怎样才能显示一个Android应用程序一个谷歌地图? [英] Android: How can I display a google map in an android app?

查看:89
本文介绍了安卓:我怎样才能显示一个Android应用程序一个谷歌地图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了一个应用程序,做一些统筹计算我。它运作良好,从我建立以及数据库中检索点。当一个菜单按钮为pressed显示地图我想现在要做的就是。我做了一个教程,是一个简单的地图显示..这一切都在运行时它。但是当我尝试纳入我在我app..I做了没有运气可言。

因此​​,这里有一些项目我已经做了,也许有人可以帮助我。

下面是重要的线从我的android的manifest.xml

 <使用库机器人:名字=com.google.android.maps机器人:所需=真/>
<使用许可权的android:NAME =android.permission.INTERNET对/>

下面是在XML的地图显示活动

 < com.google.android.maps.MapView
    机器人:ID =@ + ID /图形页面
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =FILL_PARENT
        机器人:启用=真
        机器人:可点击=真
        机器人:apiKey =0EVD3Q_WMbtaa_vIjrPoaiN7Egbs8amSorNF-QW
        />

我在我的主要应用程序,我想调用的地图菜单项(我想通过坐标太后来..但现在如果它只是简单地显示我会很乐意)在code它是case语句3,我尝试调用地图。

 公共布尔onOptionsItemSelected(菜单项项){            开关(item.getItemId()){
            情况1:
                。字符串v_band1 = spin2.getSelectedItem()的toString();
                 意图myIntent2 =新意图(Tower.this,BuildList.class);
                 myIntent2.putExtra(带,v_band1);
                 Tower.this.startActivity(myIntent2);
                返回true;
            案例2:
                 意图myIntent =新意图(Tower.this,Activity2.class);
                 Tower.this.startActivity(myIntent);
                 返回true;
            案例3:
                意图myIntent1 =新意图(Tower.this,Mapit.class);
                Tower.this.startActivity(myIntent1);
                返回true;
            情况4:
                loadspinner();
                返回true;            }
            返回false;
        }

在测试程序有一个在类的顶部导入行

 进口com.google.android.maps.MapActivity;

在我的新的应用程序,当你在import语句你开始输入进口com.google.android.maps。和MapActivity或任何不上去选择,因为它在测试教程一样。我在做什么错了?我曾尝试粘贴我整个Android Manfiest.xml ASA和XML从视图来显示地图,在这里,但整个事情并没有显示出来。所以我加了GOOGLEMAPS行来告诉你我使用它。

 <使用库机器人:名字=com.google.android.maps机器人:所需=真/>


解决方案

什么SDK是您建设?你尝试使用的功能仅在1.5或更高版本。

I have built an app that does some co-ordinate calculation for me. It works well it retrieves points from a database I built as well. What I want to do now is when a menu button is pressed display a map. I did a tutorial that is simply a map display.. that's all it does when it runs. but when I try to incorporate what I have done in my app..I have no luck at all.

So here are some of the items I have done and maybe someone can help me.

Here are the important lines from my android manifest.xml

<uses-library android:name="com.google.android.maps" android:required="true"/>
<uses-permission android:name="android.permission.INTERNET" />

Here is the the XML for the map display activity

<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"
        />

I have a menu item in my main application that I want to invoke the map( I want to pass coordinates too it later.. but right now if it would just simply display I would be happy) In this code it is the case statement 3 that I am trying to invoke the map.

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;   
        }   

in the test app there is an import line at the top of the class

import com.google.android.maps.MapActivity;

In my new app when you start typing in the import statement you get to "import com.google.android.maps." and the MapActivity or anything will not come up to select as it did in the test tutorial. What am I doing wrong?? I have tried pasted my entire Android Manfiest.xml asa well as the XML from the view to display the map, in here but the whole thing does not show up. So I added the googlemaps line to show you I use it.

<uses-library android:name="com.google.android.maps" android:required="true"/>

解决方案

What SDK are you building for? The functions you're attempting to use are only available in 1.5 or higher.

这篇关于安卓:我怎样才能显示一个Android应用程序一个谷歌地图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆