Android(google api v2)上的简单地图应用。不起作用。错误

Android(google api v2)上的简单地图应用。不起作用。错误,第1张

Android(google api v2)上的简单地图应用。不起作用。错误

在下面检查我的答案:

在您的xml文件更改

 toandroid:name="com.google.android.gms.maps.SupportMapFragment"

将您的活动扩展到FragmentActivty并进行更改

map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)) .getMap(); tomap= ((SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map)).getMap();

还要检查

if (map== null) { map= ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();}

检查清单文件:

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.example.googlemapsv2"android:versionCode="1"android:versionName="1.0" ><permission    android:name="com.example.googlemapsv2.permission.MAPS_RECEIVE"    android:protectionLevel="signature" /><uses-permission android:name="com.example.googlemapsv2.permission.MAPS_RECEIVE" /><uses-sdk    android:minSdkVersion="12"    android:targetSdkVersion="17" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /><uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /><!-- Required to show current location --><uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /><uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /><!-- Required OpenGL ES 2.0. for Maps V2 --><uses-feature    android:glEsVersion="0x00020000"    android:required="true" /><!-- Requires OpenGL ES version 2 --><uses-feature    android:glEsVersion="0x00020000"    android:required="true" /><application    android:allowBackup="true"    android:icon="@drawable/ic_launcher"    android:label="@string/app_name" >    <activity        android:name="com.example.googlemapsv2.MainActivity"        android:label="@string/app_name"        android:theme="@style/AppbaseTheme" >        <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />        </intent-filter>    </activity>    <!-- Google API Key -->    <meta-data        android:name="com.google.android.gms.version"        android:value="@integer/google_play_services_version" />    <meta-data        android:name="com.google.android.maps.v2.API_KEY"        android:value="your Google map API key" /></application>

希望这可以帮助。



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5616435.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存