目次
Android Google Maps
APIキーの取得
デバッグ用証明書の取得
C:\>keytool -list -keystore C:\Users\%USERNAME%\.android\debug.keystore -alias androiddebugkey -keypass android -storepass android androiddebugkey, 2010/04/17, PrivateKeyEntry, 証明書のフィンガープリント (MD5): 75:8C:3C:49:95:93:E6:75:09:59:4D:0D:CD:D7:F4:F1
地図を使用するためのXMLレイアウト例
<com.google.android.maps.MapView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="0XECzQxanKFclxduQGI4kGQVYajnqkCYT8Uqqww"
/>
アプリケーション準備
Google APIsを実装したエミュレータの作成
Google APIs をターゲットにしてプロジェクトを作成
アプリケーションの作成
マニフェスト
- uses-library および uses-permission 要素の追加
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="info.typea.googlemap"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".GoogleMapAppActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-library android:name="comcom.google.android.maps">
</uses-library>
</application>
<uses-permission android:name="android.permission.INTERNET">
</uses-permission>
</manifest>
MapViewを定義
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="{{取得したAPIキー}}"
/>
</LinearLayout>
Activity クラスの変更
package info.typea.googlemap;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
/**
*
* @author piroto
* @see http://code.google.com/intl/ja-JP/android/add-ons/google-apis/
*/
public class GoogleMapAppActivity extends MapActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}

YAGI Hiroto (piroto@a-net.email.ne.jp)
twitter http://twitter.com/pppiroto
Copyright© 矢木 浩人 All Rights Reserved.