0

私はアンドロイド開発に不慣れで、現在問題を抱えています。作業中のアプリ内で Google マップを動作させようとしていますが、問題が発生しています。マップが読み込まれません。

これは、アプリケーションを実行しているときの様子です。 http://i.imgur.com/QpTWmOQ.png

基本的な Google マップはありますが、サーバーからデータが提供されていないようです。これは非常に残念なことです。エミュレーターにはインターネットアクセスがあると確信しています。また、Google マップ (genymotion) と互換性がある必要があります。また、実際のAndroidデバイス(Samsung Galaxy S2)でもこれを試しました。そこでも同じことが起こります。

私のコードは次のようになります。

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

    <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="14"/>
    <uses-feature android:glEsVersion="0x00020000" android:required="true" />

    <permission android:name="no.nith.myweathermap.permission.MAPS_RECEIVE" android:protectionLevel="signature" />
    <uses-permission android:name="no.nith.weatherwap.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <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" />

    <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" >
        <uses-library android:name="com.google.android.maps"/>
        <meta-data
                android:name="com.google.android.maps.v2.API_KEY"
                android:value="myAPIkey(edited out for stackoverflow)" />
        <activity android:name=".StartActivity" android:label="@string/app_name" android:theme="@android:style/Theme.Holo">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

-

package no.nith.myweathermap;

import android.os.Bundle;
import com.google.android.maps.MapActivity;

public class StartActivity extends MapActivity {
    @Override
    protected boolean isRouteDisplayed() {
        return false;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}

レイアウト/Main.xml:

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/mapview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clickable="true"
        android:apiKey="blabla"
/>

マップがロードされない理由を特定できる人はいますか? 私はここで立ち往生しており、すべてのフィードバックと助けに大いに感謝します!

ありがとう!:)

4

4 に答える 4

0

あなたのコードを見た後、これはAndroidのマップライブラリのバージョン2ではないと思います..

新しいライブラリでは、Google Play サービス ライブラリのマップにMapFragmentまたはSupportMapFragmentを使用する必要があるため、 MapActivityからアクティビティを拡張するのは古い学校です (バージョン 1 を意味します)。

http://www.vogella.com/articles/AndroidGoogleMaps/article.htmlを取得するには、最初の簡単な例を見る必要があると思います。

これにより、新しい Android マップを使用できるようになることを願っています。

于 2013-11-08T06:42:57.683 に答える
0

Google Play サービスをプロジェクトにインポートし、Google API コンソールから Google Maps Android API v2 を有効にしましたか

おそらくこのリンクに注意する必要があると思い ます

于 2013-11-08T06:23:01.943 に答える
0

FragmentActivityの代わりに使用しMapActivityます。

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

public class MainActivity extends FragmentActivity {

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

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}

xml ファイルで次のコードを使用します。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.SupportMapFragment"/>
</RelativeLayout>

Google Play サービスのライブラリ プロジェクトをプロジェクトにインポートすることを忘れないでください。Google Play サービス プロジェクトの場所は次のとおりです。 \your-sdk\extras\google\google_play_services\libproject

于 2013-11-08T06:35:15.017 に答える