▼Androidメモ▼
Mapビューの利用


Googleマップを表示するプログラムを作成する。



android:apiKey
Googleの登録サイトからandroid:apiKeyを取得し、ソースコードのapikeyと置換。


ソースコード
MapViewEx.java
package net.npaka.mapviewex;
import android.os.*;
import android.view.*;
import com.google.android.maps.*;

//Mapビュー
public class MapViewEx extends MapActivity {

    //初期化
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        
        //Mapビューの生成(★android:apiKeyは自分のものに)
        MapView mapView=new MapView(this,"apikey");
        mapView.setEnabled(true);
        mapView.setClickable(true);
        setContentView(mapView);       
        
        //位置と拡大縮小の指定
        MapController mc=mapView.getController();   
        mc.setCenter(new GeoPoint(35707527,139760857));
        mc.setZoom(16);
    }

    //ルートの表示
    @Override
    protected boolean isRouteDisplayed() {
        return false;
    } 
}


AndroidManifest
グループ 項目名 設定値
Application user-library com.google.android.maps
Permissions user-permission android.permission.INTERNET



−戻る−