本文介绍了离线谷歌地图Android版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试按照文件在谷歌地图API的工作,但没有工作。

I try to follow documents to work with google map API, but it is not work.

我的清单

  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.gogplemap"
        android:versionCode="1"
        android:versionName="1.0" >

        <uses-sdk
            android:minSdkVersion="8"
            android:targetSdkVersion="17" />
        <permission
           android:name="com.example.gogplemap.GOOGLEMAP"
           android:protectionLevel="signature"
           ></permission>
        <uses-permission android:name="com.example.gogplemap.GoogleMap"/>
        <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <activity
                android:name="com.example.gogplemap.GoogleMap"
                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.gms.maps.MapFragment"
        android:value="AIzaSyBPQPMrlJk-Ft48z0CWvpWBRcLyrIJJ4X4"/>
        </application>

    </manifest>

我的布局activity_google_map.xml

My layout activity_google_map.xml

  <?xml version="1.0" encoding="utf-8"?>
            <fragment xmlns:android="http://schemas.android.com/apk/res/android"
                      android:id="@+id/map"
                      android:layout_width="match_parent"
                        android:layout_height="match_parent"
                      android:name="com.google.android.gms.maps.MapFragment"/>

我的方法GoogleMap.java的setContentView

My method setcontentView in GoogleMap.java

 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_google_map);
    }

非常感谢你。

推荐答案

尝试这样的方式:它会为你工作!

try like this way:it will work for you!!

布局:

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:map="http://schemas.android.com/apk/res-auto"
  android:id="@+id/map"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
 class="com.google.android.gms.maps.SupportMapFragment"/>

活动:

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

import com.google.android.gms.maps.SupportMapFragment;

public class MainActivity extends FragmentActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        SupportMapFragment fragment = new SupportMapFragment();
        getSupportFragmentManager().beginTransaction()
                .add(android.R.id.content, fragment).commit();
    }
}

清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.androidmapview"
    android:versionCode="1"
    android:versionName="1.0" >

   <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="16" />

    <permission
        android:name="com.example.androidmapview.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.example.androidmapview.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <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" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.androidmapview.MainActivity"
            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="*********************************uw"></meta-data>
    </application>

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

这篇关于离线谷歌地图Android版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 04:36