2013-04-30 39 views

回答

0

终于,我得到了解决我所做的错误是把meta_data标签被放置在应用程序标签,这是错误的之后,我们有结束标记之前指定应用标签。

像....

而且另外一个原因是我使用与它不应该以这种方式来完成API V2关键API第1版。我们必须使用API​​ V2和APIV2密钥。

我们必须使用fragment for api v2来显示您的应用和API V2密钥中的地图。这就是错误,我已经做了,这是我开发的地图应用

<fragment 
android:id="@+id/map" 
android:layout_width="match_parent" 
android:layout_height="fill_parent" 
class="com.google.android.gms.maps.SupportMapFragment" /> 

xml design file

Manifest file

知道我自己的XML数据,它看起来像清单文件和小程序,我的代码链接

step wise procedure on how to do map app

generating near by locations and marking them on map

我希望这在LEA st帮助一些新开发应用程序的人。

2

你想要实现使用MapView对象地图。 MapView对象是Google地图API V1对象,并且在API V2中不受支持。您目前的问题(没有将这两个API搞乱的事实)是API V1已被弃用,并且您无法为其生成有效的API密钥。

所以我的假设是,你已经产生了这个密钥API V2并试图用它与你的代码是Google API V1代码。这就是你没有看到地图的原因。

UPDATE:

如果你想在另一方面实行Google Map API V2,看看这个博客帖子我 关于该主题中写道:

Google Maps API V2

对于你的问题您需要使用MapFragmentSupportMapFragment,具体取决于您定位的平台。

+0

感谢,@Emil ADZ,那么什么控制我应该需要使用查看地图和我只使用谷歌API V2键。 – 2013-04-30 07:20:33

+0

看到更新的答案。 – 2013-04-30 07:23:25

1
You must register your key ay Google Services: 

All Maps API applications should load the Maps API using an API key. Using an API key enables you to monitor your application's Maps API usage, and ensures that Google can contact you about your application if necessary. If your application's Maps API usage exceeds the Usage Limits, you must load the Maps API using an API key in order to purchase additional quota. 

To create your API key, visit the APIs Console at https://code.google.com/apis/console and log in with your Google Account. 

Click the Services link from the left-hand menu, then activate the Google Maps API v2 service. 

Once the service has been activated, your API key is available from the API Access page, in the Simple API Access section. Maps API applications use the Key for browser apps. 

By default a key can be used on any site. We strongly recommend that you restrict use of your key only to domains you administer, to prevent use on unauthorized sites. You can specify which domains are allowed to use your API key by clicking the Edit allowed referrers... link for your key. 

The your must declare permissions. 

The you can do an activity with this code. 


//map Variable 
private GoogleMap mMap; 


//Set map 
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); 


//Layout 
<fragment 
    android:id="@+id/map" 
    android:name="com.google.android.gms.maps.MapFragment" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

See this to more information http://proyectosbeta.net/2012/12/configurar-y-usar-google-maps-api-v2-para-android/ 
0

我猜你需要谷歌地图API密钥添加到您的应用程序,为此,你需要在你的AndroidManifest.xml中添加应用程序元素,内以下行: <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="your_api_key"/>

+0

我已经添加了这个标签在我的清单文件@Mood – 2013-04-30 09:46:20

2

可以有3个方面的原因

1)上网查资料的权限

2)你已经使用了错误的API密钥

3)您还没有

<uses-library android:name=”com.google.android.maps” /> 
相关问题