| テクパー2020 テクニカルヘルパー | 
| アンドロイドアプリ開発 | 
| ◆ Googleマップの表示 ・ Googleのマップを表示します | 
| 【 実行 】   | 
 
      | 
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.proto.webmaps"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".WebMaps"
                  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="com.google.android.maps" />
    </application>
    <uses-permission>
      android:name="android.permission.INTERNET"
    </uses-permission>
</manifest> | 
| 
package com.proto.webmaps;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
//import android.view.Window;
public class WebMaps extends MapActivity {
/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // setContentView(R.layout.main);書き換え
        
        // ウィンドウタイトルの非表示
        // requestWindowFeature(Window.FEATURE_NO_TITLE);
        // マップビューの生成(取得のAndroid Maps API キーの設定)
        MapView mapView=new MapView(this,"0mzcivhlTzmQy1M-7pEAag6aQGrDMGiWACCEhHw");
        mapView.setEnabled(true);
        mapView.setClickable(true);
        setContentView(mapView);
        
        // マップの情報
        MapController mc=mapView.getController();
        // マップロケーション(位置)の指定
              (Googleマップのサイトから緯度(8桁)、経度(9桁)を取得)
        mc.setCenter(new GeoPoint(35609127,140113235));
        // マップズームの指定
        mc.setZoom(16);
    }
    // ルートの表示
      @Override
      protected boolean isRouteDisplayed() {
          return false;
      } 
} | 
| AndroidManifest.xml にタグを追加 <uses-sdk android:minSdkVersion="8" /> <uses-permission android:name="android.permission.INTERNET"/> | 
| import com.google.android.maps.MapActivity; に変更 import android.app.Activity; ↓ import com.google.android.maps.MapActivity; | 
| 
public class WebMaps extends MapActivity { に変更
extends Activity → MapActivity  | 
| 
com.google.android.maps のリファレンス
http://code.google.com/intl/ja/android/add-ons/google-apis/reference/
                       com/google/android/maps/package-summary.html | 
| 
com.google.android.maps のMapViewクラスの生成、指定
public MapView(android.content.Context context,java.lang.String apiKey)
(apikey にGoogleマップのサイトより取得の
           Android Maps API キー の指定)
// マップ制御の取得
public MapController getController() | 
| android.view.View のViewクラスの指定 (com.google.android.maps.MapView は android.app.Activity を継承 // ビューの有効指定(true:有効、false:無効) public void setEnabled (boolean enabled) // クリックイベントの指定(true:有効、false:無効) public void setClickable (boolean clickable) | 
| com.google.android.maps のMapControllerクラスの指定 public final class MapController() // マップの中心位置の指定(地理上の位置) public void setCenter(GeoPoint point) // マップのズーム指定(ズームレベル:1〜21) public int setZoom(int zoomLevel) | 
| com.google.android.maps のGeoPointクラスの指定 public GeoPoint(int latitudeE6, int longitudeE6) (latitudeE6:緯度 -80 〜 80)8桁 (longitudeE6:経度 -180 〜 180)9桁 // トーストの表示(アクティビティオブジェクト,表示テキスト,文字長) public static Toast makeText (Context context, CharSequence text, int duration) | 
| android.app.Activity のActivityクラスの指定 (com.google.android.maps.MapActivity は android.app.Activity を継承 // アクティビティのビューに配置(ビュー) public void setContentView (View view) | 
 2)GoogleアカウントのWebサイトからログインします
      
        (https://www.google.com/accounts/Login)
      
        ・Googleアカウントがない場合は、新規に登録します
      
        3)Android Maps API Key Siginup から 「 android:apiKey 」 を取得します
      
        (http://code.google.com/intl/ja/android/maps-api-signup.html)
      
        ・キー情報の取得設定
      
        ⇒ I have read and agree with the terms and conditions (printable version) にチェック
      
        ⇒ My certificate's MD5 fingerprint: に「証明書のフィンガープリント (MD5)」の値を入力
      
        ⇒ [Generate API Key]をクリック
      
        2)GoogleアカウントのWebサイトからログインします
      
        (https://www.google.com/accounts/Login)
      
        ・Googleアカウントがない場合は、新規に登録します
      
        3)Android Maps API Key Siginup から 「 android:apiKey 」 を取得します
      
        (http://code.google.com/intl/ja/android/maps-api-signup.html)
      
        ・キー情報の取得設定
      
        ⇒ I have read and agree with the terms and conditions (printable version) にチェック
      
        ⇒ My certificate's MD5 fingerprint: に「証明書のフィンガープリント (MD5)」の値を入力
      
        ⇒ [Generate API Key]をクリック
      
         ・キー情報の取得
      
        ・キー情報の取得
      
         
      
    | Copyright (C) 2010 プログラミングのテクニックをあなたに!!(リトル・ヘルパー) All Rights Reserved. |  |