0

i'm trying to make a sample map application, but the map doesn't appear on screen. I'm following this tutorial http://www.tutos-android.com/position-utilisateur-google-map-android and i'm using the Key for browser apps (with referers) .When i followed this tutorial http://blog.rolandl.fr/1230-android-la-geolocalisation-et-lapi-google-maps-android-v2 with the same key it worked but it gave me wrong position

4

1 回答 1

0

在第一个教程中没有提到在 Android 中使用 Google Maps 所需的 Google Maps API V2 密钥。第一个教程也适用于已弃用的 Google Maps API V1。

第二个教程绝对是您需要的。如果您的位置错误,可能是因为未使用 GPS。检查 GPS 是否已打开,并且您的 AndroidManifest.xml 中有这些行:

<uses-feature android:name="android.hardware.location.network"/>
<permission
        android:name="cz.nuc.wheelgo.permission.MAPS_RECEIVE"
        android:protectionLevel="signature"/>  <!-- replace name of the package by yours -->
<uses-permission android:name="cz.nuc.wheelgo.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<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-feature
  android:glEsVersion="0x00020000"
  android:required="true"/>
<meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzgkugSgsghsei2256Y7XN6xSGj-o"/>  <!-- your key -->

要在地图上启用您的位置,请使用:

GoogleMap mMap;
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.setMyLocationEnabled(true);

我建议您在路径中查看 Android-sdk 中的示例:android-sdk\extras\google\google_play_services\samples\maps\

于 2013-04-14T10:54:38.177 回答