| ページ一覧 | ブログ | twitter |  書式 | 書式(表) |

MyMemoWiki

「Android Google Maps」の版間の差分

提供: MyMemoWiki
ナビゲーションに移動 検索に移動
 
(同じ利用者による、間の3版が非表示)
1行目: 1行目:
==Android Google Maps==
+
==[[Android Google Maps]]==
[[Android][Java][Eclipse]]
+
[[Android]] | [[Java]] | [[Eclipse]] |
  
 
===APIキーの取得===
 
===APIキーの取得===
9行目: 9行目:
 
*http://developer.android.com/guide/publishing/app-signing.html
 
*http://developer.android.com/guide/publishing/app-signing.html
  
  C:\>keytool -list -keystore C:\Users\%USERNAME%\.android\debug.keystore -alias androiddebugkey -keypass android -storepass android
+
  C:\>keytool -list -keystore C:\Users\%USE[[R]]NAME%\.android\debug.keystore -alias androiddebugkey -keypass android -storepass android
 
  androiddebugkey, 2010/04/17, PrivateKeyEntry,
 
  androiddebugkey, 2010/04/17, PrivateKeyEntry,
 
  証明書のフィンガープリント (MD5): 75:8C:3C:49:95:93:E6:75:09:59:4D:0D:CD:D7:F4:F1
 
  証明書のフィンガープリント (MD5): 75:8C:3C:49:95:93:E6:75:09:59:4D:0D:CD:D7:F4:F1
15行目: 15行目:
 
[[File:0142_android_google_maps02.jpg]]
 
[[File:0142_android_google_maps02.jpg]]
  
====地図を使用するためのXMLレイアウト例====
+
====地図を使用するための[[XML]]レイアウト例====
 
  <com.google.android.maps.MapView
 
  <com.google.android.maps.MapView
 
                   android:layout_width="fill_parent"
 
                   android:layout_width="fill_parent"
23行目: 23行目:
  
 
===アプリケーション準備===
 
===アプリケーション準備===
====Google APIsを実装したエミュレータの作成====
+
====[[Google]] APIsを実装したエミュレータの作成====
*Menu - Window - Android SKD and AVD Manager
+
*Menu - Window - [[Android]] SKD and AVD Manager
*Virtual Devices - New
+
*Virtual De[[vi]]ces - New
*Target に Google APIs を選択
+
*Target に [[Google]] APIs を選択
 
[[File:0143_android_google_maps03.jpg]]
 
[[File:0143_android_google_maps03.jpg]]
  
====Google APIs をターゲットにしてプロジェクトを作成====
+
====[[Google]] APIs をターゲットにしてプロジェクトを作成====
 
[[File:0144_android_google_maps04.jpg]]
 
[[File:0144_android_google_maps04.jpg]]
 
===アプリケーションの作成===
 
===アプリケーションの作成===
40行目: 40行目:
 
       android:versionName="1.0">
 
       android:versionName="1.0">
 
     <application android:icon="@drawable/icon" android:label="@string/app_name">
 
     <application android:icon="@drawable/icon" android:label="@string/app_name">
         <activity android:name=".GoogleMapAppActivity"
+
         <activity android:name=".[[Google]]MapAppActivity"
 
                   android:label="@string/app_name">
 
                   android:label="@string/app_name">
 
             <intent-filter>
 
             <intent-filter>
 
                 <action android:name="android.intent.action.MAIN" />
 
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
+
                 <category android:name="android.intent.category.LAUNCHE[[R]]" />
 
             </intent-filter>
 
             </intent-filter>
         </activity>
+
         </acti[[vi]]ty>
 
         <uses-library android:name="comcom.google.android.maps">
 
         <uses-library android:name="comcom.google.android.maps">
 
         </uses-library>
 
         </uses-library>
 
     </application>
 
     </application>
 
      
 
      
     <uses-permission android:name="android.permission.INTERNET">
+
     <uses-permission android:name="android.permission.INTE[[R]]NET">
 
     </uses-permission>
 
     </uses-permission>
 
  </manifest>  
 
  </manifest>  
63行目: 63行目:
 
     >
 
     >
 
     <com.google.android.maps.MapView
 
     <com.google.android.maps.MapView
         android:id="@+id/mapview"
+
         android:id="@+id/map[[vi]]ew"
 
         android:layout_width="fill_parent"
 
         android:layout_width="fill_parent"
 
         android:layout_height="fill_parent"
 
         android:layout_height="fill_parent"
72行目: 72行目:
 
  </LinearLayout>
 
  </LinearLayout>
  
====Activity クラスの変更====
+
====Acti[[vi]]ty クラスの変更====
*Activity クラスを MapActivity クラスに置き換え
+
*Acti[[vi]]ty クラスを MapActi[[vi]]ty クラスに置き換え
*isRouteDisplayed() のオーバーライド
+
*is[[R]]outeDisplayed() のオーバーライド
 
  package info.typea.googlemap;
 
  package info.typea.googlemap;
 
   
 
   
 
  import android.os.Bundle;
 
  import android.os.Bundle;
 
   
 
   
  import com.google.android.maps.MapActivity;
+
  import com.google.android.maps.MapActi[[vi]]ty;
 
   
 
   
 
  /**
 
  /**
86行目: 86行目:
 
   * @see http://code.google.com/intl/ja-JP/android/add-ons/google-apis/
 
   * @see http://code.google.com/intl/ja-JP/android/add-ons/google-apis/
 
   */
 
   */
  public class GoogleMapAppActivity extends MapActivity {
+
  public class [[Google]]MapAppActivity extends MapActivity {
     /** Called when the activity is first created. */
+
     /** Called when the acti[[vi]]ty is first created. */
 
     @Override
 
     @Override
 
     public void onCreate(Bundle savedInstanceState) {
 
     public void onCreate(Bundle savedInstanceState) {
 
         super.onCreate(savedInstanceState);
 
         super.onCreate(savedInstanceState);
         setContentView(R.layout.main);
+
         setContentView([[R]].layout.main);
 
     }
 
     }
 
   
 
   
 
  @Override
 
  @Override
  protected boolean isRouteDisplayed() {
+
  protected boolean is[[R]]outeDisplayed() {
 
  // TODO Auto-generated method stub
 
  // TODO Auto-generated method stub
 
  return false;
 
  return false;

2020年2月16日 (日) 04:21時点における最新版

Android Google Maps

Android | Java | Eclipse |

APIキーの取得

0141 android google maps01.jpg

デバッグ用証明書の取得

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

0142 android google maps02.jpg

地図を使用するためのXMLレイアウト例

<com.google.android.maps.MapView
                 android:layout_width="fill_parent"
                 android:layout_height="fill_parent"
                 android:apiKey="0XECzQxanKFclxduQGI4kGQVYajnqkCYT8Uqqww"
                 />

アプリケーション準備

Google APIsを実装したエミュレータの作成

  • Menu - Window - Android SKD and AVD Manager
  • Virtual Devices - New
  • Target に Google APIs を選択

0143 android google maps03.jpg

Google APIs をターゲットにしてプロジェクトを作成

0144 android google maps04.jpg

アプリケーションの作成

マニフェスト

  • 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 クラスの変更

  • Activity クラスを MapActivity クラスに置き換え
  • isRouteDisplayed() のオーバーライド
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;
	}
}

実行

0145 android google maps05.jpg