使用片段未在API级别9至17中显示地图

拉贾夫·乔普拉

我有很多教程,完成了所有工作,但未在地图上显示,我总是以地图的Zoom控件视图结束,我认为清单存在问题

我的代码如下

显现:

 <application android:icon="@drawable/logo" android:label="@string/app_name" >
        <activity android:name=".Main" android:noHistory="true"
                  android:label="@string/app_name" >

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="my api key"/>

    <activity android:name="Activity2" android:label="@string/app_name" android:configChanges="keyboardHidden|orientation" />   


    </application>

    <uses-sdk android:minSdkVersion="9"   android:targetSdkVersion="10" />


    <uses-feature  android:glEsVersion="0x00020000"    android:required="true"/>   

    <uses-permission android:name="my_package_name.permission.MAPS_RECEIVE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" />
    <uses-permission android:name="android.permission.CLEAR_APP_CACHE" />
    <uses-permission android:name="android.permission.SEND_SMS" />
    <uses-permission android:name="android.permission.RECEIVE_SMS" />
    <uses-permission android:name="android.permission.WRITE_SMS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.READ_LOGS" />

我的mapview.xml是

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <fragment
        xmlns:map="http://schemas.android.com/apk/res-auto"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:id="@+id/map"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>

我的主要活动课

public class Main extends FragmentActivity  {

      private String sResponse;
      static final LatLng HAMBURG = new LatLng(53.558, 9.927);
      static final LatLng KIEL = new LatLng(53.551, 9.993);
      private GoogleMap map;

    @Override
      protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        try{
        setContentView(R.layout.mapview);

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

        LatLng sydney = new LatLng(-33.867, 151.206);

        map.setMyLocationEnabled(true);
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(sydney, 13));

        map.addMarker(new MarkerOptions()
                .title("Sydney")
                .snippet("The most populous city in Australia.")
                .position(sydney));
        }
        catch(Exception ex){

        }
     }

我不知道出了什么问题,我还从SDK导入了支持库google-play-service_lib到项目中。

编辑

当我在清单中添加此权限时

<permission
        android:name="my_package_name.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" /> 

它给我错误

Installation error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED
Please check logcat output for more details.
Launch canceled!

任何帮助..?

迪内什·拉吉(Dinesh Raj)
    <meta-data android:name="com.google.android.maps.v2.API_KEY" 
android:value="my api key"/>

像这样用您的api密钥替换“我的api密钥”

<meta-data android:name="com.google.android.maps.v2.API_KEY" 
   android:value="AIzaSyAS-3h00tgAf9nSCrwgI02DZ9zMyaIhQQY"/>

从此处获取api密钥https://code.google.com/apis/console/

有关分步教程的信息,请转到此处:地图教程

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

片段getChildFragmentManager()API级别<17

工具栏未在 Android 的 API 级别 19 中显示

syslog未在消息中显示日志级别

将Google地图实现为片段后,我在运行块中没有任何错误,但该片段未在我的设备上显示地图

Spinner 未在 kotlin 片段中显示选项

单张地图未在bootstrap div中显示

我无法在片段中显示地图

单击按钮后在片段中显示地图

片段中的谷歌地图,如何显示它

在片段中的对话框片段中显示Google地图

Android:在API级别9中使用PopupMenu

如何在API级别17使用“ setTitle”

仅当使用LayersControl的缩放级别> 8时,才在Shiny中显示传单地图中的图层。

标签未在Odoo-9中显示

在R中使用plotly时未在RStudio Viewer中显示地图

Android:RecyclerView未在片段中显示列表项

带有Choroplethmapbox的地图未在Dash中显示

Google地图未在Firebase测试实验室中显示

Google地图未在已签名的APK中显示

放置在片段中时,此处不显示地图

使用Fedora 17(32位)双重引导时,GRUB 2菜单未在菜单中显示Windows 8

使用片段的谷歌地图

API验证错误未在Laravel中显示

应用程式因「返回」而崩溃至地图片段

使用LINQ在分组对象中返回项目1至3和4至6和7至9

地图模块未在joomla 2.5实时站点中显示地图,但在localhost中工作。

ng-table标头未在IE 9中显示

片段未在ViewPager中更新

如何在旧版Android OS中使用API V2显示GoogleMap(使用地图片段的情况下使用iam)