使用MapView显示地图

时间:2014-04-10 11:22:15

标签: android android-mapview

我试图在我的Android应用中显示地图,我跟着下面的文章

https://developers.google.com/maps/documentation/android/start#install_and_configure_the_google_play_services_sdk

但活动已开始且地图未显示

以下是我的主要活动

<?xml version="1.0" encoding="utf-8"?>

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


<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="18" />

<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" />
<!--
 The following two permissions are not required to use
 Google Maps Android API v2, but are recommended.
-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <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="AIzaSyACHHKBCSoG5ZEGbNYgMhKWSsZrV3loKek" />
    <activity
        android:name="com.example.hotel.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>
    <activity
        android:name="com.example.hotel.OptionsActivity"
        android:label="@string/title_activity_options"
        android:parentActivityName="com.example.Hotel" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.example.Hotel" />
    </activity>
    <activity
        android:name="com.example.hotel.Reservation"
        android:label="@string/title_activity_reservation" >
    </activity>
    <activity
        android:name="com.example.hotel.Reservations_Activity"
        android:label="@string/title_activity_reservations_" >
    </activity>
    <activity
        android:name="com.example.hotel.ReservationDetails"
        android:label="@string/title_activity_reservation_details" >
    </activity>
    <activity
        android:name="com.example.hotel.SearchByStatus"
        android:label="@string/title_activity_search_by_status" >
    </activity>
    <activity
        android:name="com.example.hotel.SearchByHotel"
        android:label="@string/title_activity_search_by_hotel" >
    </activity>
    <activity
        android:name="com.example.hotel.ResApplication"
        android:label="@string/title_activity_res_application" >
    </activity>
    <activity
        android:name="com.example.hotel.Map"
        android:label="@string/title_activity_map" >
    </activity>


</application>

这是活动代码

<?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"/>

0 个答案:

没有答案