簡単な Google マップ ビューの作成中に問題が発生しました。以下に私のコードを見つけることができます:
マニフェスト:
<uses-sdk
android:minSdkVersion="8"/>
<uses-permission android:name="android.permission.INTERNET"/>
<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.maps.v2.API_KEY"
android:value="AIzaSyB0zPyFFyQ_sCVmMjj6pgNqvqKg3zHGMSs"/>
<activity
android:name="com.example.maptest.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<category android:name="android.intent.category.EMBED"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-library android:name="com.google.android.maps"/>
</application>
Java ファイル内:
public class MainActivity extends MapActivity {
private MapView mapView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mapView = (MapView)findViewById(R.id.map);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
XML ファイルで:
<com.google.android.maps.MapView
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:apiKey="AIzaSyB0zPyFFyQ_sCVmMjj6pgNqvqKg3zHGMSs"
android:clickable="true" >
</com.google.android.maps.MapView>
結果は開始アプリです。魔女は地図の代わりに灰色の領域を表示しますが、典型的な Google アイコンが隅に表示されます。
最も一般的な問題は間違った API キーであることはわかっていますが、頻繁に確認したところ、キーは正しいものでした。多分誰かが提案を持っていますか?