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

MyMemoWiki

「Android Google Maps」の版間の差分

提供: MyMemoWiki
ナビゲーションに移動 検索に移動
(ページの作成:「==Android Google Maps== [Android][Java][Eclipse] ===APIキーの取得=== *http://code.google.com/intl/ja/android/maps-api-signup.html File:0141_android_google_ma…」)
 
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\%USERNAME%\.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
16行目: 16行目:
  
 
====地図を使用するためのXMLレイアウト例====
 
====地図を使用するためのXMLレイアウト例====
  <com.google.android.maps.MapView
+
  &lt;com.google.android.maps.MapView
 
                   android:layout_width="fill_parent"
 
                   android:layout_width="fill_parent"
 
                   android:layout_height="fill_parent"
 
                   android:layout_height="fill_parent"
 
                   android:apiKey="0XECzQxanKFclxduQGI4kGQVYajnqkCYT8Uqqww"
 
                   android:apiKey="0XECzQxanKFclxduQGI4kGQVYajnqkCYT8Uqqww"
                   />
+
                   /&gt;
  
 
===アプリケーション準備===
 
===アプリケーション準備===
34行目: 34行目:
 
====マニフェスト====
 
====マニフェスト====
 
*uses-library および uses-permission 要素の追加
 
*uses-library および uses-permission 要素の追加
  <?xml version="1.0" encoding="utf-8"?>
+
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
+
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
 
       package="info.typea.googlemap"
 
       package="info.typea.googlemap"
 
       android:versionCode="1"
 
       android:versionCode="1"
       android:versionName="1.0">
+
       android:versionName="1.0"&gt;
     <application android:icon="@drawable/icon" android:label="@string/app_name">
+
     &lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt;
         <activity android:name=".GoogleMapAppActivity"
+
         &lt;activity android:name=".GoogleMapAppActivity"
                   android:label="@string/app_name">
+
                   android:label="@string/app_name"&gt;
             <intent-filter>
+
             &lt;intent-filter&gt;
                 <action android:name="android.intent.action.MAIN" />
+
                 &lt;action android:name="android.intent.action.MAIN" /&gt;
                 <category android:name="android.intent.category.LAUNCHER" />
+
                 &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
             </intent-filter>
+
             &lt;/intent-filter&gt;
         </activity>
+
         &lt;/activity&gt;
         <uses-library android:name="comcom.google.android.maps">
+
         &lt;uses-library android:name="comcom.google.android.maps"&gt;
         </uses-library>
+
         &lt;/uses-library&gt;
     </application>
+
     &lt;/application&gt;
 
      
 
      
     <uses-permission android:name="android.permission.INTERNET">
+
     &lt;uses-permission android:name="android.permission.INTERNET"&gt;
     </uses-permission>
+
     &lt;/uses-permission&gt;
  </manifest>
+
  &lt;/manifest&gt;
  
 
====MapViewを定義====
 
====MapViewを定義====
  <?xml version="1.0" encoding="utf-8"?>
+
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 
     android:orientation="vertical"
 
     android:orientation="vertical"
 
     android:layout_width="fill_parent"
 
     android:layout_width="fill_parent"
 
     android:layout_height="fill_parent"
 
     android:layout_height="fill_parent"
     >
+
     &gt;
     <com.google.android.maps.MapView
+
     &lt;com.google.android.maps.MapView
 
         android:id="@+id/mapview"
 
         android:id="@+id/mapview"
 
         android:layout_width="fill_parent"
 
         android:layout_width="fill_parent"
69行目: 69行目:
 
         android:clickable="true"
 
         android:clickable="true"
 
         android:apiKey="{{取得したAPIキー}}"
 
         android:apiKey="{{取得したAPIキー}}"
     />
+
     /&gt;
  </LinearLayout>
+
  &lt;/LinearLayout&gt;
  
 
====Activity クラスの変更====
 
====Activity クラスの変更====

2020年2月15日 (土) 08:00時点における版

Android Google Maps

[[Android][Java][Eclipse]]

APIキーの取得

0141 android google maps01.jpg

デバッグ用証明書の取得

  1. C:\>keytool -list -keystore C:\Users\%USERNAME%\.android\debug.keystore -alias androiddebugkey -keypass android -storepass android
  2. androiddebugkey, 2010/04/17, PrivateKeyEntry,
  3. 証明書のフィンガープリント (MD5): 75:8C:3C:49:95:93:E6:75:09:59:4D:0D:CD:D7:F4:F1

0142 android google maps02.jpg

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

  1. <com.google.android.maps.MapView
  2. android:layout_width="fill_parent"
  3. android:layout_height="fill_parent"
  4. android:apiKey="0XECzQxanKFclxduQGI4kGQVYajnqkCYT8Uqqww"
  5. />

アプリケーション準備

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 要素の追加
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3. package="info.typea.googlemap"
  4. android:versionCode="1"
  5. android:versionName="1.0">
  6. <application android:icon="@drawable/icon" android:label="@string/app_name">
  7. <activity android:name=".GoogleMapAppActivity"
  8. android:label="@string/app_name">
  9. <intent-filter>
  10. <action android:name="android.intent.action.MAIN" />
  11. <category android:name="android.intent.category.LAUNCHER" />
  12. </intent-filter>
  13. </activity>
  14. <uses-library android:name="comcom.google.android.maps">
  15. </uses-library>
  16. </application>
  17. <uses-permission android:name="android.permission.INTERNET">
  18. </uses-permission>
  19. </manifest>

MapViewを定義

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:orientation="vertical"
  4. android:layout_width="fill_parent"
  5. android:layout_height="fill_parent"
  6. >
  7. <com.google.android.maps.MapView
  8. android:id="@+id/mapview"
  9. android:layout_width="fill_parent"
  10. android:layout_height="fill_parent"
  11. android:enabled="true"
  12. android:clickable="true"
  13. android:apiKey="テンプレート:取得したAPIキー"
  14. />
  15. </LinearLayout>

Activity クラスの変更

  • Activity クラスを MapActivity クラスに置き換え
  • isRouteDisplayed() のオーバーライド
  1. package info.typea.googlemap;
  2.  
  3. import android.os.Bundle;
  4.  
  5. import com.google.android.maps.MapActivity;
  6.  
  7. /**
  8. *
  9. * @author piroto
  10. * @see http://code.google.com/intl/ja-JP/android/add-ons/google-apis/
  11. */
  12. public class GoogleMapAppActivity extends MapActivity {
  13. /** Called when the activity is first created. */
  14. @Override
  15. public void onCreate(Bundle savedInstanceState) {
  16. super.onCreate(savedInstanceState);
  17. setContentView(R.layout.main);
  18. }
  19.  
  20. @Override
  21. protected boolean isRouteDisplayed() {
  22. // TODO Auto-generated method stub
  23. return false;
  24. }
  25. }

実行

0145 android google maps05.jpg